"Attempted to read or write protected memory" error on Win7 - activeX control failure
We have a windows application (.net, VS2010) that uses an old wrapped activeX control (VSPrinter 8 from ComponentOne, to be precise. vsprint8.ocx). Th开发者_运维百科is handles all of our printing and print previews. When we deploy and run our application to a fresh instance of Win7 on a VM (32 bit), and do something that attempts to invoke this control, we receive the following error:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
It continues to work fine on Windows XP. Interestingly, if we turn off DEP on the target VM (systemwide, set to AlwaysOff), the application works. But if we turn off DEP on just the executable that uses the ocx, it doesn't work.
Any ideas? Thanks!
Found a solution.
I couldn't effectively turn off DEP on the executable in question, so I added the following lines to the post-build event command line in VS2010 and it fixed my problem:
call "$(DevEnvDir)\..\..\VC\bin\vcvars32.bat"
call "$(DevEnvDir)\..\..\VC\bin\editbin.exe" /NXCOMPAT:NO "$(TargetPath)"
In the VS Solution Explorer, right click the project under the solution, select Properties, and click Build Events. You'll see the "Post-build event command line:" text box which is where you plug the above stuff in.
This effectively disabled DEP for my app. Here's the blog post that helped me see the light. Thanks, random dude!
http://jtstroup.net/post/Attempted-to-read-or-write-protected-memory-This-is-often-an-indication-that-other-memory-is-corrupt.aspx
精彩评论