How to solve 'Attempted to read or write protected memory…' error with programmatic approach for WebBrowser component?

谁都会走 提交于 2019-12-11 18:55:49

问题


I have a windows application which uses a form containing WebBrowser component. I never found this error message in the navigate method of it, till OS Vista. But it only shows up for OS Windows 7.

Yes, solutions - 1) At post build - call "$(DevEnvDir)....\VC\bin\vcvars32.bat" call "$(DevEnvDir)....\VC\bin\editbin.exe" /NXCOMPAT:NO "$(TargetPath)"

2) editbin.exe /NXCOMPAT:NO YourProgram.exe

works for me, but I need a programmatic approach. If any one can help me about it. Thanks in advance... :).


回答1:


You can add this to your postbuild events in your project.

http://jtstroup.net/post/Attempted-to-read-or-write-protected-memory-This-is-often-an-indication-that-other-memory-is-corrupt.aspx




回答2:


You could p/Invoke SetProcessDEPPolicy. Note that this can be overridden by an AlwaysOn system-wide DEP policy.



来源:https://stackoverflow.com/questions/2809489/how-to-solve-attempted-to-read-or-write-protected-memory-error-with-prog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!