Friday, May 10, 2013

ActiveX Control not working .Net 4.5


We recently moved our application from .Net 4.0 to .Net 4.5. After that, our few component which were based on ActiveX component stopped working IE.

After a lot research , we found a solution. As with launch of .Net, Hosting managed controls inside IE is no longer supported out of the box.

Further Details : http://msdn.microsoft.com/en-us/library/hh367887.aspx

Here is one way that you can use if you want to load ActiveX Control in IE 10. 

Solution:


There is registry key called as "EnableIEHosting". This key needs to be added at two location:

  • HKLM\SOFTWARE\MICROSOFT\.NETFramework
  • HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework

Please create key of type "dword" and set its value to 1 e.g.

"EnableIEHosting"=dword:00000001

Thats it! You ActiveX controls are all set to load in IE 10 on any Windows operating system with .NET 4.5

You can create these entries either using code or simple run a batch file. 

Create Batch File :


REGEDIT4

; @ECHO OFF
; CLS
; REGEDIT.EXE /S "%~f0"
; EXIT

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
"EnableIEHosting"=dword:00000001


[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework]
"EnableIEHosting"=dword:00000001

Pause

Copy this content and save it in file ".bat" extension.  No code needed :)

Hope it helps!





3 comments:

  1. Thanks a lot for that post. Proved very helpful.

    I tried the suggested solution and worked just fine for ASP.net web form application. I wonder if are there are any additional settings to be done for an ASP.Net MVC4 applications. Using the suggested solution, I am still facing the same issue for an MVC4 web application.

    Any help will be much appreciated.

    Gitika.

    ReplyDelete
  2. Hi Gitika,

    This is not related to Technologies. Further I'll suggest following way, you can try to develop ActiveX as suggested here [http://www.olavaukan.com/2010/08/creating-an-activex-control-in-net-using-c/]

    Further, install that component and use in your application. Important things to remember, you should have a unique GUID for each class.

    ReplyDelete
  3. Thanks mate, I ran into the same problem and your solution solved the issue

    Many thanks

    ReplyDelete