Attempted to read or write protected memory

后端 未结 13 1492
予麋鹿
予麋鹿 2020-11-27 16:07

I\'ve started seeing an AccessViolationException being thrown in my application a several different spots. It never occured on my development pc, our test server. It also o

相关标签:
13条回答
  • 2020-11-27 16:39

    Hi There are two possible reasons.

    1. We have un-managed code and we are calling it from managed code. that is preventing to run this code. try running these commands and restart your pc

      cmd: netsh winsock reset

    open cmd.exe and run command "netsh winsock reset catalog"

    1. Anti-virus is considering un-managed code as harmful and restricting to run this code disable anti-virus and then check
    0 讨论(0)
  • 2020-11-27 16:41

    In my case fonts used in one of the shared library was not installed in the system.

    0 讨论(0)
  • 2020-11-27 16:45

    In my case I had trouble with the "Environment variables" while adding reference to my COM DLL.

    When I added the reference to my project, I was looking for P:\Core path, whereas I had added the c:\core path in past into path environment varaible.

    So my code was attempting wrong path first. I removed that and un-registered the DLL reference and re-registered my DLL reference using (regsvr32). Hope this helps.

    0 讨论(0)
  • 2020-11-27 16:48

    Microsoft also released a hotfix (July 2nd, 2007) to prevent the error "Attempted to read or write protected memory" that has been plaguing the .NET 2.0 platform for some time now. Look at http://support.microsoft.com/kb/923028 - not sure if it applies to you, but thought you might like to check it out.

    0 讨论(0)
  • 2020-11-27 16:48

    The problem may be due to mixed build platforms DLLs in the project. i.e You build your project to Any CPU but have some DLLs in the project already built for x86 platform. These will cause random crashes because of different memory mapping of 32bit and 64bit architecture. If all the DLLs are built for one platform the problem can be solved. For safety try bulinding for 32bit x86 architecture because it is the most compatible.

    0 讨论(0)
  • 2020-11-27 16:49

    For VS 2013, .NET Framework 4.5.1 also has a AccessViolationException bug (KB2915689) when dealing with SQL Server / TCP Sockets. Upgrading to .NET Framework 4.5.2 corrects this problem.

    Reported VS.NET AccessViolationException

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

    0 讨论(0)
提交回复
热议问题