Attempt to read or write to protected memory

2

I have an application in C# that connects to the Oracle database. For this the application makes use of NHibernate (a very old version) and Castle ActiveRecord . This has always worked, but now when I try to query the database I get a System.AcessViolationException , which says:

  

Attempt to read or write to protected memory. Usually, this is an indication that another memory is corrupted.

The intriguing thing is that on all other computers here, everything works perfectly. I've seen a lot about this in the past few days, but nothing has helped me sort it out. I even looked for the error in English:

  

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

I ended up finding other people who had this problem with NHibernate and / or ActiveRecord . Unfortunately updating NHibernate or not using ActiveRecord is not a valid option. I'm sure this error is not specific to these libs , but I can not find a solution for this.

The stacktrace of the first exception is:

em System.Data.Common.UnsafeNativeMethods.OCIServerAttach(OciHandle srvhp, OciHandle errhp, Byte[] dblink, Int32 dblink_len, MODE mode)
   em System.Data.OracleClient.TracedNativeMethods.OCIServerAttach(OciHandle srvhp, OciHandle errhp, String dblink, Int32 dblink_len, MODE mode)
   em System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
   em System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
   em System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   em System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   em System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   em System.Data.OracleClient.OracleConnection.Open()
   em NHibernate.Connection.DriverConnectionProvider.GetConnection()

EDIT

I uninstalled the Oracle I had on my machine and now I'm getting the error:

  

System.Data.OracleClient requires Oracle client software version 8.1.7 or later.

I've reinstalled the Instant Client and the other project that makes the same connections is working normal ...

    
asked by anonymous 27.03.2015 / 12:48

1 answer

5

I'll leave you logged in here as I solved this problem, should anyone come across it.

This first error was caused by the fact that I was using a local x64 database and my instant client was x86. I was not using the local bank, but anyway I solved uninstalling bank. The second error was because my user was not allowed to read / write to the instant client folder, so what I needed to do was give those permissions to my user and restart the PC. >     

30.03.2015 / 14:30