Loading .NET UserControls in IE with .NET 4.0

前端 未结 2 599
误落风尘
误落风尘 2020-12-17 04:37

I\'ve got a legacy app where there\'s a UserControl which is used as an activex in a web page loaded in IE. Before .NET 4.0, there were security policies and a MMC console

相关标签:
2条回答
  • 2020-12-17 04:57

    Ok, after several tests, I've managed to make it work. Here are some things you should keep in mind:

    • you cannot compile your assembly against .NET 4.0 because IEHost was deprecated in .NET 4.0. So, you'll have to compile against .NET 3.5
    • Since you're compiling against .NET 3.5, don't forget to set the correct security policies in the .NET 2.0 configuration console

    And, the most important thing of all: don't forget to set the policies in the correct version of .NET. In my case, I'm running on a x64 machine and so I went ahead and installed the x64 bits version. setting the correct policies in the installed console didn't really work, so I had to download and install the x86 version. After doing that, everything started working well (after all, IE was running as a 32 bit app)

    Once again, I can't really understand MS' decision of deprecating IEHost without introducing a new option.

    0 讨论(0)
  • 2020-12-17 05:02

    Hosting controls in IE is now blocked by default (as of v4 or v4.5). See MSDN article under 'Web Applications'.

    Fortunately it is super-easy to re-enable the functionality with these reg keys:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
    "EnableIEHosting"=dword:00000001
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework]
    "EnableIEHosting"=dword:00000001
    

    The x64 key was the one that fixed it for me, running IE8 (x32) on Win7 (x64) using a .Net v3.5 SP1 control compiled for x32.

    0 讨论(0)
提交回复
热议问题