简体   繁体   中英

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

I'm having troubles at implementing and ASP .Net Application in IIS 6 Server.

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

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Oracle.DataAccess.Client.OpsPrm.ResetValCtx(OpoPrmValCtx* pOpoPrmValCtx, Int32 ctxSize) at Oracle.DataAccess.Client.OracleParameter.ResetCtx(Int32 arraySize) at Oracle.DataAccess.Client.OracleParameter.PreBind(OracleConnection conn, IntPtr errCtx, Int32 arraySize) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader() at Oracle.DataAccess.Client.OracleCommand.ExecuteScalar() at Tenaris.FSA.OracleProvider.OracleProvider.ExecuteScalar(String commandToExecute, CommandType commandType, DbParameter[] parameters) in C:\\Congelados FSA\\FSA 1er Entregable 05052013\\Tenaris.FSA.OracleProvider\\OracleProvider.cs:line 223 at Tenaris.FSA.DAC.Providers.DataAccessManager.ExecuteScalar(String commandToExecute, CommandType commandType, DbParameter[] parameters) in C:\\Congelados FSA\\FSA 1er Entregable 05052013\\Tenaris.FSA.DataAccessComponent\\Providers\\DataAccessManager.cs:line 59 a t Tenaris.FSA.DAC.Repository.AppointmentWayClientDAL.GetCountRegisters(Boolean onlyEnabled) in C:\\Congelados FSA\\FSA 1er Entregable 05052013\\Tenaris.FSA.DataAccessComponent\\Repository\\AppointmentWayClientDAL.cs:line 39 at Tenaris.FSA.BusinessComponents.BusinessProcess.AppointmentWayClientManager.GetCountRegisters(Boolean onlyEnabled) in C:\\Congelados FSA\\FSA 1er Entregable 05052013\\Tenaris.FSA.BusinessComponents\\BusinessProcess\\AppointmentWayClientManager.cs:line 28

What's rare, because that error is not supposed to appear in managed code, and the previous version of the site is working fine. I've done several tests, like compiling the app in an x86 platform pc, copied the web.config from the functional version, copied the Oracle.DataAccess dll from the functional version, but the error still showing.

Another thing you should know is that there is a page that, actually succeded in filling a dropdownlist, but then the page has to fill a gridview and there appears the above exception.

I could finally solve the issue, another developer used a "using" clause while creating OracleParameters, it was like:

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

So the code had to change to:

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

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

So, The code was Disposing the object before using it. What I can't understand is why is this even working in a console application that was one of my tests, but well it is working now, Thank you everyone

系统已经用完ram来加载它,所以当它试图从受保护的内存的其他应用程序中获取更多时,这样可以获得更多内存

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM