Attempted to read or write protected memory error in TransactionScope with OracleClient(10g)

We are randomly getting this error message on our development and staging machines:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.; at System.Data.Common.UnsafeNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)
at System.Data.OracleClient.TracedNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)
at System.Data.OracleClient.OracleInternalConnection.Enlist(String userName, String password, String serverName, Transaction transaction, Boolean manualEnlistment)
at System.Data.OracleClient.OracleInternalConnection.Activate(Transaction transaction)
at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OracleClient.OracleConnection.Open()

We are using VS2005, C#, Oracle 10g Client, and the TransactionScope. When we get this error, it's usually either on the opening of the connection OR on the execution of the proc/package. We had to install the client, then install, as a separate package the oracle support for MTS which supports transactions.

Here is a snippet of code that causes this error:

using (TransactionScope scope = new TransactionScope())

{

using (IDbConnection connection = this.GetConnection())

{

connection.Open();

...DO SOME STUFF

try

{

command.ExecuteNonQuery();

foreach (IDataParameter parameter in command.Parameters)

{

if( parameter.Direction.Equals( ParameterDirection.InputOutput ) || parameter.Direction.Equals( ParameterDirection.Output ) )

returnParameters.Add(parameter);

}

}

catch (Exception ex)

{

// ERROR HANDLING HERE

}

}

}

scope.Complete();

}

Like I said, it happens randomly, but when it does occur, it's on one of those two methods Open or Execute. Does anyone have any idea why this breaks down




Answer this question

Attempted to read or write protected memory error in TransactionScope with OracleClient(10g)

  • mic90264

    We have the same problem.

    Damjan


  • Hema Bairavan

    I'm having the exact same problem with system.transactions and oracle 9i on a 2003 server.  I've contacted microsoft support and they are investigating, but from the analysis I've done so far, it certainly looks to be an oracle problem of some sort.  what a bag of sh*t that product is.  Have you or anyone else that you know of found a solution that doesn't involve removing system.transactions from your app

  • Ludwig

    I routinely experience this error when developing, but not when the app is released. The solution for me is simple:

    Ensure the Distributed Transaction Coordinator service is started (set Startup = Automatic)

    Perform a Clean Solution from the build menu, then re-run your app


  • delasare

    I doubt anyone is still active on this particular thread, but I thought I would post this as a follow up anyway.  After a fair amount of debate between my colleagues and I and the Oracle DBAs/Support people in the organization I am currently contracted with, we migrated our application to a server with the 10g Client installed and lo and behold no more problems.  We never got a real solid answer from either Microsoft or Oracle as to why this seems to have resolved the issue, but my personal suspsision is that it had to do with privs and the oracle installation relative to DTC.  So this might explain why the person with the original post had the issue with 10g originally. 

  • Jamie Sellars

    We encountered the exact same problem today. The problem turned out to be that our parameter names exceeded 30 characters!

    So, if you seeing this problem make sure all of your parameter names are less than 30 characters long as a first step. :-)

  • marius bogdan

    Looks like somebody is corrupting your application memory.

    You can try using the Application Verifier to see who is doing that: http://www.microsoft.com/technet/prodtechnol/windows/appcompatibility/appverifier.mspx

    Hope this helps.



  • Connie Daniel

    Thanks for the update. It is good to hear your problem is solved.

  • Attempted to read or write protected memory error in TransactionScope with OracleClient(10g)