Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading .NET UserControls in IE with .NET 4.0

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 for creating code groups, etc. It seems like that is all gone with .NET 4.0.

I was wondering if someone could give me some clues on how to update my UserControl project so that it works against .NET 4.0. I've been running some tests and none of them seem to work. In fact, I've noticed that if I update the .NET version of my UserControl to 4.0 before compilint it, it won't even be added to the GAC download area. It gets downloaded (used fiddler to test it) but it simply isn't added to the GAC's download area. Setting the .NET platform version to 3.5 or below, means that the dll is added to the GAC but it's still unusable from the web page (the old JS code that worked before keeps saying that it cannot find member X on object Y).

So, can anyone point me to the right direction? What do I need to do in .NET 4.0 to load a .NET UserControl in Internet Explorer?

thanks.

like image 296
Luis Abreu Avatar asked Jul 26 '10 12:07

Luis Abreu


1 Answers

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.

like image 136
cuzzlor Avatar answered Oct 03 '22 02:10

cuzzlor