System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt..
If you have VS2005 C++ Unit Tests, written in managed C++ as they should be, and you are calling native code from them, and you see that error when running your unit tests – I have found it to mean that you are using insecure versions of methods (strcpy, etc). If you change the method calls to the secure versions, you should see your tests pass!
3 replies on “VS2005 C++ Unit Tests – System.AccessViolationException: Attempted to read or write protected memory.”
What if you are calling a .dll and don’t have te source code of it? In that case I won’t be able to change the problematic functions (almost all of the dll) to the secure version. Any tip on this?
LikeLike
hmm, not sure what you can do in that case then. if it is a 3rd party dll, I suggest contacting the creator and bugging them to change it. If it is an internal created dll, then maybe try finding the source, or creating a new dll yourself with the same functionality if it isn’t too huge or complicated.
LikeLike
It’s an internal created dll, but from another department. I’ll try to get the original code or at least an example of how are they using that old dll with their new code. Thanks for the help.
LikeLike