winform compatibility with IE8

Here is an overview of the compatibility issue we had for winform with IE8.

First tests using winform with IE8 showed that we the winform was opened, IE8 crashed

It was possible to open the winform with IE8 in compatibility mode, however this is not the native mode of IE8

I had a closer look to what happened:

  • It seems that IE8 requires the dll Microsoft.mshtml.dll (in version 7.0.3300.0) to be present on the user’s computer when opening a web page embedding a winform control (even for a simple winform control this dll is required).
  • Because of the following code in class UserControlBase when the winform is opened in IE8 on a computer where this dll is not present, the event AssemblyResolve is fired (because the dll could not be found). This code then tries to reload this assembly but this fires the AssemblyResolve event and a new attempt to load this dll is made … and so on …. And after more than 200 attemps IE8 crashes because of a stack overflow
        public UserControlBase()

        {

            _currentBaseUserControl = this;

            InitializeComponent();

            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolveEventHandler);

        }

        private System.Reflection.Assembly AssemblyResolveEventHandler(object sender, ResolveEventArgs args)

        {

            return System.Reflection.Assembly.Load(args.Name);

        } 
  • This code has been added at the beginning of the project  because we sometimes had problems opening the winform. A Microsoft consultant who helped us during this rewriting added this code and this fixed these problems.

This dll is part of the .Net 2.0 SDK; so it will be complicated to install this on the users’ computers so that they have this dll on their machines.

 

We have found that when the Microsoft.mshtml.dll (of version 7.0.3300.0) is present in the /res folder of the web site (along with the winform dlls), when this dll is “needed” by IE8 for opening the winform it is downloaded from the res folder of the web site and the event AssemblyResolve was not fired anymore(which fixes the IE8 compatibility issue).

To make winform compatible with IE8 we just need to place Microsoft.mshtml.dll (of version 7.0.3300.0) in the res folder of the web site.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值