views:

636

answers:

6

Hello,

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?

+1  A: 

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

Stuart Dunkeld
A: 

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

Wolf5
A: 

It's not 64 bit.

Turning off the Visual Studio Hosting Process worked for debugging.

However, upon creating a setup project which uses the primary output of my sample project, and installing the project from the Visual Studio menu, I get the same error. So perhaps the post build event isn't being applied, or something in the setup project is overriding that setting?

Any ideas? I'm unsure of whether the post build event is applied in setup projects.

David Hodgson
A: 

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.

Pat
A: 

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.

David Hodgson
+1  A: 

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

Stuart Dunkeld