gpt4 book ai didi

C# WebBrowser 控制 System.AccessViolationException

转载 作者:IT王子 更新时间:2023-10-29 04:11:33 25 4
gpt4 key购买 nike

我有一个使用内置网络浏览器控件的程序。在使用这个过程中的某个时刻,我不确定在什么时候,但它似乎是随机的,我收到以下错误:

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)

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

最佳答案

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

可能有助于诊断是否是同一个问题的症状 - jscript.dll 未在调试器的模块中列出,并且未被进程加载;崩溃的 native 堆栈跟踪如下:

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 库,崩溃应该会消失。

按如下方式重新注册库(针对 64 位 Windows 给出的示例,否则只需要第一行):

C:\Windows\System32\regsvr32.exe C:\Windows\System32\jscript.dll
C:\Windows\SysWOW64\regsvr32.exe C:\Windows\SysWOW64\jscript.dll

这两个命令都必须是“以管理员身份运行”。

关于C# WebBrowser 控制 System.AccessViolationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/178898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com