C# Web 浏览器控制 System.AccessViolationException [英] C# WebBrowser Control System.AccessViolationException

查看:23
本文介绍了C# Web 浏览器控制 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)

有没有人知道我为什么会得到这个以及如何防止它?

Does anyone have any clues as to why I would get this and how to prevent it?

推荐答案

我们最近在几个客户的机器上遇到了类似的问题.结果证明该问题是某些环境中 MSHTML 控件中的错误.该问题的一个常见症状似乎是 jscript.dll 库的注册损坏.

We have recently had a similar problem on the 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 the 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:WindowsSystem32
egsvr32.exe C:WindowsSystem32jscript.dll
C:WindowsSysWOW64
egsvr32.exe C:WindowsSysWOW64jscript.dll

两个命令都必须是以管理员身份运行".

Both commands have to be "Run as Administrator".

这篇关于C# Web 浏览器控制 System.AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆