Wednesday, May 5, 2010

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

In C# .net  3.5 64 bit platform remoting service.

This was one of those frustrating issues which takes forever to figure out what’s happening.

I have a distributed application where the web tier accesses the middle tier on a remoting service. One of the middle tier methods accepts a struct parameter. This method, when invoked from web tier on a 32 bit platform worked fine, but on 64 bit platform it threw the exception “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”

Looks like the Struct being a value type was getting messed up when passed across process boundaries through remoting. I think what was happening was the remoting service was trying to access the asp.net’s copy of struct instance. I changed the data type from struct to class and its now working fine now

1 comment:

  1. This keeps happening to us when running our 32 bits server applications on 64 bits machine. We are not passing any struct parameters and have no idea where to look for the problem.
    Our .net applications are compiled with x86 compiler directive because it calls a 32 bits DLL.
    Any idea for a starting point

    ReplyDelete