Attempted to read or write protected memory in a .NET application

I am having problems deploying and deploying ASP.Net on IIS 6.

When a user tries to open a web page that accesses the database, the iis server throws "Trying to read or write protected memory", this is StackTrace:

System.AccessViolationException: attempt to read or write protected Memory. This often indicates that another memory is corrupted. in Oracle.DataAccess.Client.OpsPrm.ResetValCtx (OpoPrmValCtx * pOpoPrmValCtx, Int32 ctxSize) in Oracle.DataAccess.Client.OracleParameter.ResetCtx (Int32 arraySize) Intra Oracle.DataAccess.Client.OraclePrrtprtrmeterParartrtrmeterParartrtrmeter arraySize) in Oracle.DataAccess.Client.OracleCommand.ExecuteReader (Boolean requery, Boolean fillRequest, CommandBehavior behavior) in Oracle.DataAccess.Client.OracleCommand.ExecuteReader () in Oracle.DataAccess.Client.OracleCommand.ExecuteScarar () in Ten .OracleProvider.OracleProvider.ExecuteScalar (command parameters String commandToExecute, CommandType, DbParameter []) in C: \ Congelados FSA \ FSA 1er Entregable 05052013 \ Tenaris.FSA.OracleProvider \ OracleProvider.cs: line 223 in Tenaris.FSA.DFS.FSA.Diders.DFSAFS.DFS .DataAccessManager.ExecuteScalar (commandToExecute, CommandType commandType, DbParameter [] string) in C: \ Congelados FSA \ FSA 1er Entregable 05052013 \ Tenaris.FSA.Data AccessComponent \ Providers \ DataAccessManager.cs: line 59 in Tenaris.FSA.DAC.Repository.AppointmentWayClientDAL.GetCountRegisters (Boolean onlyEnabled) in C: \ Congelados FSA \ FSA 1er Entregable 05052013 \ Tenaris.FSA.DatagetCompositalient line 39 at Tenaris.FSA.BusinessComponents.BusinessProcess.AppointmentWayClientManager.GetCountRegisters (Boolean onlyEnabled) at C: \ Congelados FSA \ FSA 1er Entregable 05052013 \ Tenaris.FSA.BusinessComponents \ BusinessProcess \ AppointmentWayClient 28

Which is rare, because this error should not appear in managed code, and the previous version of the site is working fine. I conducted several tests, for example, compiling the application on an x86 platform PC, copied web.config from the functional version, copied the Oracle.DataAccess dll from the functional version, but the error still appears.

Another thing you should know is that there is a page that, in fact, was populated with a drop-down list, but then the page should populate the gridview and the above exception appears.

+6
source share
2 answers

I could finally solve the problem, another developer used the "using" clause when creating OracleParameters, it was like:

using(OracleParameter prm = SomeMethodThatCreatesIt(value,paramName)) { //extracode myCommand.Parameters.Add(prm); } 

Therefore, the code should have changed to:

 OracleParameter prm = SomeMethodThatCreatesIt(value,paramName); //extracode myCommand.Parameters.Add(prm); 

As you can see in stacktrace, the problem was in some process for the parameters.

So, the Code was a Disposing object before using it. I don’t understand why this works even in a console application, which was one of my tests, but it works well now, thanks everyone.

+1
source

the system has ended up using ram to load it, so when it tries to extract more from other applications that are protected memory, get more ram

0
source

Source: https://habr.com/ru/post/945096/


All Articles