2

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?

Matt Hamilton
  • 200,371
  • 61
  • 386
  • 320
David Hodgson
  • 10,104
  • 17
  • 56
  • 77
  • Your link is broken, use this: http://jtstroup.net/post/Attempted-to-read-or-write-protected-memory-This-is-often-an-indication-that-other-memory-is-corrupt.aspx – Eyal Mar 16 '10 at 09:54

6 Answers6

1

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

stuartd
  • 70,509
  • 14
  • 132
  • 163
1

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

stuartd
  • 70,509
  • 14
  • 132
  • 163
0

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

Aaron
  • 1
0

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

Wolf5
  • 16,600
  • 12
  • 59
  • 58
0

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
  • 5,263
  • 1
  • 36
  • 53
0

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
  • 10,104
  • 17
  • 56
  • 77