This discussion is archived
14 Replies Latest reply: Mar 18, 2010 12:27 AM by 760919 RSS

Attempted to read or write protected memory. This is often an indication...

445476 Newbie
Currently Being Moderated
I receive the following error when debugging, but not when running the release version of my .NET 2.0 program:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt"

It's quite bizarre! I dont really know what else would be needed, but I can provide DLL versions etc if someone asks. Ive posted this in Ora/MTS forum because it only seems to happen when using a transaction on the client side
  • 1. Re: Attempted to read or write protected memory. This is often an indicatio
    529532 Newbie
    Currently Being Moderated
    Hi

    We have the exact same problem, only it's also in the release version. It definitly has something to do with transactions, the exception comes from oramts.

    After the machine is started, it comes when the fist access through Oracle provider is made. Then it never appears until the machine is rebooted again.

    We have worked around this problem by triggering the problem on purpose, and swallows it, when the applications starts. Not very pretty, but better than having the customer getting an exception for the first data access made.
  • 2. Re: Attempted to read or write protected memory. This is often an indicatio
    407846 Newbie
    Currently Being Moderated
    I had the same problem. I opened a call at MS. But after several days waiting and several calls costing time and money I gave up. It's most probably a bug in MTS...not using it anymore since then.
  • 3. Re: Attempted to read or write protected memory. This is often an indicatio
    543909 Newbie
    Currently Being Moderated
    I've got the same...

    [AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
    System.Data.Common.UnsafeNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans) +0
    System.Data.OracleClient.TracedNativeMethods.OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans) +71
    System.Data.OracleClient.OciEnlistContext.Join(OracleInternalConnection internalConnection, Transaction indigoTransaction) +55
    System.Data.OracleClient.OracleInternalConnection.Enlist(String userName, String password, String serverName, Transaction transaction, Boolean manualEnlistment) +301
    System.Data.OracleClient.OracleInternalConnection.Activate(Transaction transaction) +174
    System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction) +54
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1497
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +160
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +122
    System.Data.OracleClient.OracleConnection.Open() +55

    Environment:
    Oracle 9.2 and SQL Server 2000
    .NET 2.0
    MS OracleClient
    MTS by System.Transaction
    Oracle Services for Microsoft Transaction Server 9.2.0.7.0
    Windows XP SP 2
  • 4. Re: Attempted to read or write protected memory. This is often an indicatio
    579641 Newbie
    Currently Being Moderated
    I'm having the same problem when trying to fetch a REF CURSOR into an OracleDataReader. The error comes up when I call the .Read method of the datareader.

    I've been scouring forums since yesterday afternoon and have yet to find an answer that solved the problem. Is there any fresh intel on this?

    Thanks,
    JV
  • 5. Re: Attempted to read or write protected memory. This is often an indicatio
    user220424 Newbie
    Currently Being Moderated
    Make sure that Distributed Transaction Coordinator (MS DTC) service Startup is set to start automatically.
  • 6. Re: Attempted to read or write protected memory. This is often an indicatio
    445476 Newbie
    Currently Being Moderated
    Other things you can try:


    Ensure that the oramts.dll is up to date. Oracle released a debug version with one of their packages and many systems have this version. It causes the error.

    Even when you updated the dll, ensure you do a CLEAN of your .NET project before your rebuild it. Every time I forget to clean before I rebuild, i get this error, in release or debug mode. CLEAN removes all old/half compiled .NET objects.
  • 7. Re: Attempted to read or write protected memory. This is often an indicatio
    591956 Newbie
    Currently Being Moderated
    Make sure that Distributed Transaction Coordinator (MS DTC) service Startup is set to start automatically.
    I had the same problem and this was exactly the cause. My machine, which I reboot every day, did not start this process automatically. So always on the first try I would get that error, and then I wouldn't see it again until the next day. Our prod box never gets reset so it has never occurred there.

    Definetly try this first.
  • 8. Re: Attempted to read or write protected memory. This is often an indicatio
    633592 Newbie
    Currently Being Moderated
    By making this change does it affect anything else within the system?
  • 9. Re: Attempted to read or write protected memory. This is often an indicatio
    217816 Newbie
    Currently Being Moderated
    Has anyone seen this message occur without any ORA- error associated with it?

    Every 10-15 hours we're getting the error "System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." but no ORA error stack accompanying it.

    In this case, would it be a .Net error as opposed to an ODP/ODAC error?

    Any thoughts?
  • 10. Re: Attempted to read or write protected memory. This is often an indicatio
    673124 Newbie
    Currently Being Moderated
    Exists different causes for this problem... but in my case I solved changing in the file sqlnet.ora the value : SQLNET.AUTHENTICATION_SERVICES= (NONE)
  • 11. Re: Attempted to read or write protected memory. This is often an indication...
    656582 Newbie
    Currently Being Moderated
    Hi I have similar issue. Like others, it seems that the error returned by oracle make ASP.NET (w3wp.exe) to have runtime error.
    In my case, it occurs about once every day, consistently. The ASP still work even after runtime error but start to take up high cpu usage after 2nd and 3rd time of error, and totally crash (no reponse to the client request) after 3 or 4 times of errors. It recovers back after the server is restarted.


    The following is from event log of my server.
    -------------------------------------------------------------------------------
    Event Type:     Error
    Event Source:     ASP.NET 2.0.50727.0
    Event Category:     None
    Event ID:     1334
    Date:          1/15/2009
    Time:          10:10:02 AM
    User:          N/A
    Computer:     AXMAN
    Description:
    An unhandled exception occurred and the process was terminated.

    Application ID: /LM/W3SVC/1/Root/rais

    Process ID: 5984

    Exception: System.AccessViolationException

    Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    StackTrace: at System.Data.Common.UnsafeNativeMethods.OCIServerAttach(OciHandle srvhp, OciHandle errhp, Byte[] dblink, Int32 dblink_len, MODE mode)
    at System.Data.OracleClient.TracedNativeMethods.OCIServerAttach(OciHandle srvhp, OciHandle errhp, String dblink, Int32 dblink_len, MODE mode)
    at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
    at System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
    at System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionPool.PoolCreateRequest(Object state)
    at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
    at System.Threading.ExecutionContext.runTryCode(Object userData)
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
    -------------------------------------------------------------------------------
  • 12. Re: Attempted to read or write protected memory. This is often an indication...
    542526 Newbie
    Currently Being Moderated
    Hello did you get it fix?
  • 13. Re: Attempted to read or write protected memory. This is often an indication...
    754862 Newbie
    Currently Being Moderated
    I still have that problem ...

    2/19/2010 2:37:17 AM Verbose (Ifs.SM.Client) [1] - Logging on...
    2/19/2010 2:37:17 AM Info (Ifs.SM.Client) [1] - Ifs.SM.Presentation.Client.LogonConfiguration
    2/19/2010 2:37:17 AM Error (Ifs.SM.Client) [1] - OracleLogonInternal
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    at Oracle.DataAccess.Client.OpsTrace.GetRegTraceInfo(UInt32& TrcLevel, UInt32& StmtCacheSize)
    at Oracle.DataAccess.Client.OraTrace.GetRegistryTraceInfo()
    at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
    at Ifs.SM.Data.DataAccess.OracleBase.GetConnection()
    at Ifs.SM.Data.DataAccess.OracleAuthenticationDataAccessor.LogonInternal(String username, String password, String idLng, String dataSource, AuthenticationType type, DatabaseLocationType location)
    2/19/2010 2:37:18 AM Error (Ifs.SM.Client) [1] - IFS Sales and Marketing Client has encountered a problem! Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    on a Windows 2003 R2 x64 Server with .Net 3.5 and SP's

    does anyone found a solutin for that ?
  • 14. Re: Attempted to read or write protected memory. This is often an indication...
    760919 Newbie
    Currently Being Moderated
    dear friend,

    maybe i can offer solution for your w3wp.exe service, did you ready set up an Default Application Pool on IIS ? if you not ready setup your default application pool, i think you will be got a problem about w3wp, cause in application pool you can setup for your memory, process even in crash, the service will be automatic restart w3wp service.