Question

I have written a basic Windows Form app in C# that has an embedded web browser control. I am navigating to a page to view a camera's feed. The application works fine on Windows XP, but not on Vista.

On Vista, I get a AccessViolationException. This seems to be related to Data Execution Prevention.

The article at http://jtstroup.net/CommentView,guid,3fa30293-a3a4-4a1c-a612-058e751ad151.aspx has a couple solutions. The fix at the bottom of the page, editbin.exe /NXCOMPAT:NO YourProgram.exe from a Visual Studio Command Prompt works just fine.

However, what I'd like is to use the post build event method, by adding the following as suggested:

REM Mark project as DEP Noncompliant call "$(DevEnvDir)....\VC\bin\vcvars32.bat" call "$(DevEnvDir)....\VC\bin\editbin.exe" /NXCOMPAT:NO "$(TargetPath)"

However, this doesn't work when I try to run the program through the debugger (i.e. I get the same exception).

Any ideas?

Was it helpful?

Solution

According to this article:

Because It was observed in a Setup project with Visual Studio 2008 that the Add Project Output source path Points to c:\App\OBJ*.exePost Build Event would update c:\app\BIN*.exe and not the OBJ.

Manually add the build in setup and deployment Project Create New Setup Project | Add File | select Build EXE which is under Bin Folder

OTHER TIPS

Turn off the Visual Studio Hosting Process, or alternatively mark the hosting process (yourapp.vshost.exe) as DEP noncompliant?

Question. The vista version you are trying. Is it 64bit? If so, compile the code to x86 only and try.

Does the page you are viewing contain a java applet <applet>? I've encountered this exact issue and traced it to that. It's due to the WebBrowser Control using Microsoft's JVM which is now not supported I believe.

They are ActiveX controls, not applets.

Again, the program works if I apply editbin.exe from a Visual Studio Command Prompt, or if I use that post build event as above, and turn off the Visual Studio Hosting Process.

It's when I run create a setup/deployment project, run the installer, and then try to run the program that it still crashes. The client machines likely won't have Visual Studio, and I so can't run editbin.exe on the target machine after deployment - it needs to fire in the setup/deployment project. So I'm guessing that either the post-build event from the primary output isn't being fired, or it is and there's something reenabling DEP in the deployment project.

I had to add another line to my post build event

call "$(DevEnvDir)..\tools\vsvars32.bat" editbin.exe /NXCOMPAT:NO "$(TargetPath)" editbin.exe /NXCOMPAT:NO "$(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName)"

this edits the exe in the obj folder. It seems that is what my Deployment project uses.

I got the idea from here. Microsoft Forum

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top