{"id":2586,"date":"2022-08-30T15:26:06","date_gmt":"2022-08-30T15:26:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/04\/accessviolationexception-with-a-webbrowser-in-a-windows-form-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:26:06","modified_gmt":"2022-08-30T15:26:06","slug":"accessviolationexception-with-a-webbrowser-in-a-windows-form-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/accessviolationexception-with-a-webbrowser-in-a-windows-form-collection-of-common-programming-errors\/","title":{"rendered":"AccessViolationException with a webbrowser in a windows form-Collection of common programming errors"},"content":{"rendered":"<p>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&#8217;s feed. The application works fine on Windows XP, but not on Vista.<\/p>\n<p>On Vista, I get a AccessViolationException. This seems to be related to Data Execution Prevention.<\/p>\n<p>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.<\/p>\n<p>However, what I&#8217;d like is to use the post build event method, by adding the following as suggested:<\/p>\n<p>REM Mark project as DEP Noncompliant call &#8220;$(DevEnvDir)&#8230;.\\VC\\bin\\vcvars32.bat&#8221; call &#8220;$(DevEnvDir)&#8230;.\\VC\\bin\\editbin.exe&#8221; \/NXCOMPAT:NO &#8220;$(TargetPath)&#8221;<\/p>\n<p>However, this doesn&#8217;t work when I try to run the program through the debugger (i.e. I get the same exception).<\/p>\n<p>Any ideas?<\/p>\n<ol>\n<li>\n<p>According to this article:<\/p>\n<blockquote>\n<p>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.<\/p>\n<p>Manually add the build in setup and deployment Project Create New Setup Project | Add File | select Build EXE which is under Bin Folder<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>Question. The vista version you are trying. Is it 64bit? If so, compile the code to x86 only and try.<\/p>\n<\/li>\n<li>\n<p>It&#8217;s not 64 bit.<\/p>\n<p>Turning off the Visual Studio Hosting Process worked for debugging.<\/p>\n<p>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&#8217;t being applied, or something in the setup project is overriding that setting?<\/p>\n<p>Any ideas? I&#8217;m unsure of whether the post build event is applied in setup projects.<\/p>\n<\/li>\n<li>\n<p>Does the page you are viewing contain a java applet ? I&#8217;ve encountered this exact issue and traced it to that. It&#8217;s due to the WebBrowser Control using Microsoft&#8217;s JVM which is now not supported I believe.<\/p>\n<\/li>\n<li>\n<p>I had to add another line to my post build event<\/p>\n<p>call &#8220;$(DevEnvDir)..\\tools\\vsvars32.bat&#8221; editbin.exe \/NXCOMPAT:NO &#8220;$(TargetPath)&#8221; editbin.exe \/NXCOMPAT:NO &#8220;$(ProjectDir)obj\\$(ConfigurationName)\\$(TargetFileName)&#8221;<\/p>\n<p>this edits the exe in the obj folder. It seems that is what my Deployment project uses.<\/p>\n<p>I got the idea from here. Microsoft Forum<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-02-04 02:07:05. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2586","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2586"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2586\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}