在安装IE9后使用WebBrowser控件应用程序崩溃 [英] Application that uses WebBrowser control crashes after installing IE9

查看:1104
本文介绍了在安装IE9后使用WebBrowser控件应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上个星期安装了IE 9,因为我的C#.NET应用程序崩溃的时候20%左右。调试器是无法显示的东西,除了在Program.cs的Application.Run停止有用的(新MyMainForm()); ,顺便说一句的主要形式已经显示,所以它不是,它的东西在建筑的主要形式。



我有Windows7的。

 引发的异常是:
类型'System.ArgumentException的未处理的异常出现在System.Windows.Forms.dll中
$ b $ 。b附加信息:值不在预期范围内

调用堆栈的屏幕快照 - > <一个HREF =htt​​p://img861.imageshack.us/f/ie9v.png/> http://img861.imageshack.us/f/ie9v.png/



在运行调试器之外,这个信息显示:

 问题签名:
问题事件名称:APPCRASH
应用名称:MYEXE.EXE
应用程序版本:6.7.6.0
应用时间戳:4d7fdffd
故障模块名称:Mshtml.dll的
故障模块版本: 9.0.8112.16421
故障模块时间戳:4d76266c
异常代码:C0000005
异常偏移:0012c848
OS版本:6.1.7600.2.0.0.256.48
区域设置ID:1037

和有时代替Mshtml.dll的它说StackHash_f09d

问题事件名称:APPCRASH
应用名称:MYEXE.EXE
应用程序版本:6.7。 6.0
应用时间戳:4d7fdffd
故障模块名称:StackHash_f09d
故障模块版本:0.0.0.0
故障模块时间戳:00000000
异常代码:C0000005
异常偏移:00000000
OS版本:6.1.7600.2.0.0.256.48
区域设置ID:1037

在此先感谢



编辑:



这就是我看到WinDbg中,用符号:

  0:000> KB 
ChildEBP RetAddr参数为儿童
0020eda4 64d54f83 0566c988 00001012 00000000 MSHTML!CDOC :: ReduceMemoryPressureTask + 0X1A
0020edb4 64d54f2c c6b991e4 0020ee78 00000113 MSHTML!GWYieldToMsgOnCurrentThread + 0x17b
0020edfc 770086ef 00192392 00000012 0000201b MSHTML!GlobalWndProc + 0x1f2
0020ee28 77008876 64d54afe 00192392 00000113 USER32!InternalCallWinProc + 0x23
0020eea0 770089b5 00000000 64d54afe 00192392 USER32!UserCallWinProcCheckWow + 0x14b
0020ef00 77008e9c 64d54afe 00000000 0020ef2c USER32!DispatchMessageWorker + 0x35e $ b $ !b 0020ef10 03b54726 0020ef9c fa69a961 00000000 USER32 DispatchMessageW + 0xF的
***警告:无法验证校验和C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Windows.Forms\f92c882fd4e7005c005​​e208daa04c28d\\ \\System.Windows.Forms.ni.dll
警告:帧IP没有任何已知的模块。以下帧可能是错误的。
0020ef2c 5af78aee 01b743e4 00000001 01ac95cc 0x3b54726
0020efe0 5af78757 00000000 FFFFFFFF 00000000 System_Windows_Forms_ni + 0x208aee
0020f038 5af785a1 01b6c610 1f3a000e 00000000 System_Windows_Forms_ni + 0x208757
0020f068 5af35911 01bb7d84 0020f10c 003b73d8 System_Windows_Forms_ni + 0x2085a1
0020f0e0 6f221b5c 015b1141 00000001 0020f170 System_Windows_Forms_ni + 0x1c5911
0020f0f0 6f232209 0020f1c0 00000000 0020f190 mscorwks!CallDescrWorker + 0x33
0020f170 6f246511 0020f1c0 00000000 0020f190 mscorwks!CallDescrWorkerWithHandler + 0xA3执行
0020f2b4 6f246544 0032c040 0020f380 0020f34c mscorwks!方法描述:: CallDescr + 0x19c
0020f2d0 6f246562 0032c040 0020f380 0020f34c mscorwks方法描述:: CallTargetWorker + 0x1F的
0020f2e8 6f2b0c45 0020f34c d847bc11 00000000 mscorwks MethodDescCallSite :: CallWithValueTypes + 0X1A
0020f44c 6f2b0b65 003239c0 ​​00000001 0020f488 mscorwks的ClassLoader !!!: :!RunMain + 0x223
0020f6b4 6f2b10b5 00000000 00000001 d847b3d9大会mscorwks :: ExecuteMainMethod + 0xa6
0020fb84 6f2b129f 013a0000 00000000 d847b389 mscorwks SystemDomain :: ExecuteMainMethod + 0x456

===== UPDATE(我不知道,如果我应该张贴的回答你的问题)===== =======
谢谢大家努力帮助,我很感激。



作为绝望了,我开始删除的代码段,了解哪些我的代码部分影响(我们使用webrowser多种形式控制)。删除呼叫LoginForm的也使用webrowser控制后,问题消失。



登录表单主机webrowser控制,它定位到特定的URL,例如/login.php,如果用户已经登录的,里面的形式方法UserLoggedIn从调用HTML中使用ObjectForScripting。当UserLoggedIn叫,我们调用Close()来关闭形式,如果被证明的LoginForm的。尽管LoginForm的在做这一切,我们总是不显示它。我们,显示它只有在X秒后UserLoggedIn()不叫(即用户需要登录)。
由于某种原因,并感谢MS为使我们能够调试进入.NET源,当我们调用Close,而形式是不可见的是实际处理的形式和它所有的孩子,因为IsHandleCreated是假的。现在,关闭从UserLoggedIn(),这是由浏览器控件激发的事件称为(调用堆栈显示ieframe.dll,Mshtml.dll的等),所以WebBrowser对象正在而来自被称为destoyed。
的哈克的方式来解决这个问题,是要求关闭,只有形式是可见。顺便说一句,我不知道,为什么IsHandleCreated是假的,如果我们不展示形式。我试图重现它,通过写一个创建的形式,这未示出的样品,但它的IsHandleCreated为真



----从Forms.cs - 如果----

 公共无效关闭()
{

(GETSTATE( STATE_CREATINGHANDLE))
抛出新的InvalidOperationException异常(SR.GetString(SR.ClosingWhileCreatingHandle,关闭));

如果(IsHandleCreated){
closeReason = CloseReason.UserClosing;
的SendMessage(NativeMethods.WM_CLOSE,0,0);
}
,否则{
// MSDN:当窗体关闭时,对象物的内部创建的所有资源都关闭,并且形式被布置。
// MDI子:MdiChildren集合被更新(VSWhidbey#368642&安培; 93550)
的Dispose(); //这个被调用时的形式是不可见
}
}


解决方案

在JSCRIPT.DLL正确注册此崩溃发生。该ReduceMemoryPressureTask方法希望将其加载并导致null取消引用除外。一个修复程序到受影响的计算机上运行 REGSVR32 JSCRIPT.DLL 。您可以通过查看加载模块列表,查看JSCRIPT.DLL缺失或不检查错误。这是可以做到无论是编程或通过的Process Explorer


I've installed IE 9 last week and since, my c# .net application crashes about 20% of times. The debugger is unable to show something useful besides stopping at Program.cs Application.Run(new MyMainForm()); , btw the main form was already shown, so it's not that it's something in construction on main form.

I have Windows7.

The exception thrown is:
"An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll

Additional information: Value does not fall within the expected range.

Screen shot of callstack -> http://img861.imageshack.us/f/ie9v.png/

When running outside of debugger, this info is shown:

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: myexe.exe
  Application Version:  6.7.6.0
  Application Timestamp:    4d7fdffd
  Fault Module Name:    mshtml.dll
  Fault Module Version: 9.0.8112.16421
  Fault Module Timestamp:   4d76266c
  Exception Code:   c0000005
  Exception Offset: 0012c848
  OS Version:   6.1.7600.2.0.0.256.48
  Locale ID:    1037

And sometimes instead of mshtml.dll it says StackHash_f09d

Problem Event Name: APPCRASH
  Application Name: myexe.exe
  Application Version:  6.7.6.0
  Application Timestamp:    4d7fdffd
  Fault Module Name:    StackHash_f09d
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Code:   c0000005
  Exception Offset: 00000000
  OS Version:   6.1.7600.2.0.0.256.48
  Locale ID:    1037

Thanks in advance

Edited:

That's what I see in windbg, with symbols:

0:000> kb
ChildEBP RetAddr  Args to Child              
0020eda4 64d54f83 0566c988 00001012 00000000 mshtml!CDoc::ReduceMemoryPressureTask+0x1a
0020edb4 64d54f2c c6b991e4 0020ee78 00000113 mshtml!GWYieldToMsgOnCurrentThread+0x17b
0020edfc 770086ef 00192392 00000012 0000201b mshtml!GlobalWndProc+0x1f2
0020ee28 77008876 64d54afe 00192392 00000113 USER32!InternalCallWinProc+0x23
0020eea0 770089b5 00000000 64d54afe 00192392 USER32!UserCallWinProcCheckWow+0x14b
0020ef00 77008e9c 64d54afe 00000000 0020ef2c USER32!DispatchMessageWorker+0x35e
0020ef10 03b54726 0020ef9c fa69a961 00000000 USER32!DispatchMessageW+0xf
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Windows.Forms\f92c882fd4e7005c005e208daa04c28d\System.Windows.Forms.ni.dll
WARNING: Frame IP not in any known module. Following frames may be wrong.
0020ef2c 5af78aee 01b743e4 00000001 01ac95cc 0x3b54726
0020efe0 5af78757 00000000 ffffffff 00000000 System_Windows_Forms_ni+0x208aee
0020f038 5af785a1 01b6c610 1f3a000e 00000000 System_Windows_Forms_ni+0x208757
0020f068 5af35911 01bb7d84 0020f10c 003b73d8 System_Windows_Forms_ni+0x2085a1
0020f0e0 6f221b5c 015b1141 00000001 0020f170 System_Windows_Forms_ni+0x1c5911
0020f0f0 6f232209 0020f1c0 00000000 0020f190 mscorwks!CallDescrWorker+0x33
0020f170 6f246511 0020f1c0 00000000 0020f190 mscorwks!CallDescrWorkerWithHandler+0xa3
0020f2b4 6f246544 0032c040 0020f380 0020f34c mscorwks!MethodDesc::CallDescr+0x19c
0020f2d0 6f246562 0032c040 0020f380 0020f34c mscorwks!MethodDesc::CallTargetWorker+0x1f
0020f2e8 6f2b0c45 0020f34c d847bc11 00000000 mscorwks!MethodDescCallSite::CallWithValueTypes+0x1a
0020f44c 6f2b0b65 003239c0 00000001 0020f488 mscorwks!ClassLoader::RunMain+0x223
0020f6b4 6f2b10b5 00000000 d847b3d9 00000001 mscorwks!Assembly::ExecuteMainMethod+0xa6
0020fb84 6f2b129f 013a0000 00000000 d847b389 mscorwks!SystemDomain::ExecuteMainMethod+0x456

=====UPDATE(I'm not sure, if I'm supposed to post it as "Answer your question")============ Thanks to everyone trying to help, I appreciate it.

Being desperate, I started to remove pieces of code to understand which part of my code affects it(we use webrowser control in many forms). After removing call to LoginForm which also uses webrowser control, the problem disappeared.

The login form hosts webrowser control, it navigates to certain url, for example /login.php and if user is already logged-in, method UserLoggedIn inside form is invoked from html using ObjectForScripting. When UserLoggedIn was called, we were calling Close() to close form if the LoginForm was shown. Even though LoginForm was doing all this, we weren't always showing it. We were, showing it only if after X seconds UserLoggedIn() was not called(i.e user needs to login). For some reason, and thanks to MS for making us able to debug into .net sources, when we were calling Close, and the form was not Visible it was actually disposing the form and all it's children because IsHandleCreated was false. Now, the Close was called from UserLoggedIn(), which is an event fired by the browser control(the callstack shows ieframe.dll, mshtml.dll etc) , so the webbrowser object was being destoyed while being called from. The hacky way to resolve this, was to call Close, only if form was Visible. BTW, I don't know, why IsHandleCreated is false, if we don't show the form. I tried to reproduce it, by writing a sample that creates a form, which is not shown, but it's IsHandleCreated is true.

---- from Forms.cs -----

        public void Close() 
        { 

        if (GetState(STATE_CREATINGHANDLE)) 
            throw new InvalidOperationException(SR.GetString(SR.ClosingWhileCreatingHandle, "Close"));

        if (IsHandleCreated) {
            closeReason = CloseReason.UserClosing; 
            SendMessage(NativeMethods.WM_CLOSE, 0, 0);
        } 
        else{ 
            // MSDN: When a form is closed, all resources created within the object are closed and the form is disposed.
            // For MDI child: MdiChildren collection gets updated (VSWhidbey# 368642 & 93550) 
            Dispose(); // THIS WAS CALLED WHEN FORM WAS NOT VISIBLE
        }
    }

解决方案

This crash happens when jscript.dll is incorrectly registered. The ReduceMemoryPressureTask method expects it to be loaded and causes a null dereference otherwise. A fix is to run regsvr32 jscript.dll on the affected machine. You can check for the error by looking at the loaded module list to see if jscript.dll is missing or not. This can be done either programatically or through Process Explorer.

这篇关于在安装IE9后使用WebBrowser控件应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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