C#WebBrowser控件System.AccessViolationException [英] C# WebBrowser Control System.AccessViolationException
问题描述
我有一个使用内置的WebBrowser控件的程序。在这个使用过程中的一些问题,我不知道在什么时候,但它似乎是随机的,我得到以下错误:
I have a program that uses the built in webbrowser control. At some point during the usage of this, I'm not sure at what point, but it appears to be random, I get the following error:
System.AccessViolationException
FullText = System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
有没有人有任何线索,为什么我会得到这个问题以及如何prevent呢?
Does anyone have any clues as to why I would get this and how to prevent it?
推荐答案
我们最近有类似的问题对多个客户机。原来,这个问题是在MSHTML控制在特定环境中的错误。一个常见的症状的问题似乎被打破登记JSCRIPT.DLL库。
We have recently had similar problem on machines of several customers. The problem turned out to be a bug in the MSHTML control in certain environments. A common symptom for the problem seems to be broken registration of the jscript.dll library.
症状,可以帮助诊断,如果是同一个问题 - JSCRIPT.DLL未列在模块中的调试器,而不是由进程加载;飞机失事本地堆栈跟踪如下:
Symptoms that may help to diagnose if it's the same problem - the jscript.dll is not listed in Modules in the debugger and is not loaded by the process; Native stack trace for the crash is the following:
mshtml!CRootTracker::CollectGarbageInternal+0xd
mshtml!CDoc::ReduceMemoryPressureTask+0x29
mshtml!CStackPtrAry<unsigned long,12>::GetStackSize+0xb6
mshtml!GlobalWndProc+0x183
USER32!InternalCallWinProc+0x23
USER32!UserCallWinProcCheckWow+0x109
USER32!DispatchMessageWorker+0x3bc
USER32!DispatchMessageW+0xf
解决的办法是重新注册的jscript.dll库和崩溃应该走了。
The solution is to re-register the jscript.dll library and the crash should go away.
重新注册该库做如下(例如给出了64位的Windows,否则,只有第一行是必要的):
Re-registering the library is done as follows (example given for 64-bit Windows, otherwise only the first line is necessary):
C:\Windows\System32\regsvr32.exe C:\Windows\System32\jscript.dll
C:\Windows\SysWOW64\regsvr32.exe C:\Windows\SysWOW64\jscript.dll
这两个命令都必须以管理员身份运行。
Both commands have to be "Run as Administrator".
这篇关于C#WebBrowser控件System.AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!