2

im having a hard time correcting this bug, the app is tested on 4 diffrent machines and works fine on 3 of them but one vista PC gives this error when trying to open a page trough WebBrower1

anyhelp resolving this wold be very helpful to me.

System.AccessViolationException occurred
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="System.Windows.Forms"
StackTrace:
   ved System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   ved System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   ved System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   ved System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   ved System.Windows.Forms.Application.Run(Form mainForm)
   ved Dispatcher_Tool.Program.Main() i C:\Users\norah\Downloads\Kopi av Dispacher Tool_utvikling\Dispacher Tool\Program.cs:linje 18
InnerException: 

Update:

i have found out that that my code is not the issue, i tryed creating a test new form with only a webBrowser and the direct URL for opening the Web page.

the web page starts, then the script on the web page opens a secondary page that seems to try to redirect my webBrowser1 to the page the script tells it too.

if i set webBrowser1.AllowNavigation = False i dont get the Crash so the error seems to happen when teh script trys to update in webBrowser1, anyone got a clue how to work around this?

Darkmage
  • 1,583
  • 9
  • 24
  • 42
  • It looks very strange that your question describes the error happening through a WebBrowser, yet the (partial) exception stack shows the exception happening in the inner loop of System.Windows.Forms. Is this a Windows Forms or ASP.NET application? – Jeremy McGee Dec 16 '09 at 15:40
  • it is a Windows form, the webBrowser1 is starting a site that runs som java applets, then i get this error, happens same place every time. – Darkmage Dec 16 '09 at 15:43
  • oki the problem looks to be not in my code, i tryed making a clean form no buttons only a webBrowser pointing to the same site, and i get the error again. i also find this http://stackoverflow.com/questions/178898/c-webbrowser-control-system-accessviolationexception same problem and still with Vista,, something very wrong here. – Darkmage Dec 16 '09 at 15:51

1 Answers1

4

It was a Vista Issue, what happens was that my App opens a web page that runs a java applet that opens a external IE webpage that runs a ActiveX app/script. When the ActiveX script tryes to update back in to the memory of the C# app the DEP "Data Execution Prevention" in Vista flags this operation as Hostile/virus and ends the program with the System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

My fix for this was to turn of DEP in Vista with this line "bcdedit.exe /set {current} nx AlwaysOff"

and reboot the machine.

Darkmage
  • 1,583
  • 9
  • 24
  • 42