How to import/use a DLL but not in debug mode?

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
I'm facing an issue using the Transactions namespace with the System.Data.OracleClient

Something on the system, I suspect an oracle DLL, does not like having a debugger attached to it; As soon as I attempt to run any database related statement within a transactionscope, while in debug mode (though not necessarily singlestepping), i receive an error message saying "Attempt to read or write protected memory"

I'm presuming this is caused by the debugger attampting to attach to what oracle's driver dll code is doing. If i run the project in Release mode the code works perfectly. I havent had an answer from oracle, so i'm wondering if I can prevent the debugger from attaching to anything related to System.Data.OracleClient or any library within the transactions namespace?
 
You can only choose debug/release mode at application level for the process, the debugger attaches the process, not at the individual assemblies referenced by the application process. But you can choose different type exceptions to break on in the Debug Exceptions dialog. Which one to uncheck for this particular problem to not try to make a break should be CLR System.AccessViolationException but it doesn't mean the exception doesn't happen and is thrown, it just means that the debugger doesn't break into code on this exception.
 
Thing is - this is a progress-blocking exception; I cannot fix the cause of the exception because it occurs outside of code I wrote:


VB.NET:
[SIZE=1]at System.Data.Common.UnsafeNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)[/SIZE]
[SIZE=1]at System.Data.OracleClient.TracedNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)[/SIZE]
[SIZE=1]at System.Data.OracleClient.OracleInternalConnection.Enlist(String userName, String password, String serverName, Transaction transaction, Boolean manualEnlistment)[/SIZE]
[SIZE=1]at System.Data.OracleClient.OracleInternalConnection.Activate(Transaction transaction)[/SIZE]
[SIZE=1]at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)[/SIZE]
[SIZE=1]at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)[/SIZE]
[SIZE=1]at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)[/SIZE]
[SIZE=1]at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)[/SIZE]
[SIZE=1]at System.Data.OracleClient.OracleConnection.Open()[/SIZE]
[SIZE=1]at System.Data.Common.DbDataAdapter.UpdateConnectionOpen(IDbConnection connection, StatementType statementType, IDbConnection[] connections, ConnectionState[] connectionStates, Boolean useSelectConnectionState)[/SIZE]
[SIZE=1]at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)[/SIZE]
[SIZE=1]at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)[/SIZE]
[SIZE=1]at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)[/SIZE]
[SIZE=1]at DDHub.HubDSTableAdapters.DDH_CLIENTSTableAdapter.Update(DDH_CLIENTSDataTable dataTable) in C:\Documents and Settings\matt.whittle\Desktop\Software Dev\Local\Visual Studio 2005\Projects\DDHub\DDHub\DDHub\HubDS.Designer.vb:line 9887[/SIZE]
[SIZE=1]at DDHub.frmClientDetail.DDH_CLIENTSBindingNavigatorSaveItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\matt.whittle\Desktop\Software Dev\Local\Visual Studio 2005\Projects\DDHub\DDHub\DDHub\ModedForms\frmClientDetail.vb:line 275"[/SIZE]


As noted, the code works in release, but not in debug.. Is there an option other than declaring a variable in Settings called "DisableTransactions":

If My.Settings.DisableTransactions Then
'run update code
Else
'setup transaction
'run updatecode
'complete transaction
EndIf

seems a shame to have to implement that..
 
Back
Top