Embedding ActiveX Object in HTML (IE 11)

Simple Way

- Create a Class Library in C# (VS 2010, .NET 4.0)

- Set Assembly COM Visible

- IN Code: using System.Runtime.InteropServices;

- Add a Public Interface with all Properties and Functions you need

- Derive your Public Class from that Interface

- Decorate your Class with [ClassInterface(ClassInterfaceType.AutoDual)]

- Implement All Properties and Memberfunctions your Interface needs

- Sign your Assembly (in Project Properties)

- Build Your Assembly

- Register your Assembly (RegASM <dllfilename> /tlb /codebase

- Create HTML File with Script Block

<html> <head> <script language="javascript"> <!-- Load the ActiveX object --> var x = new ActiveXObject("<namespacename>.<classname"); <!-- Access the Method --> alert(x.Memberfunctionname());</script> </head> <body> </body> </html>

- IE Security: Site must be in trusted Sites

- Usually Localhost is NOT Trusted

- It doesn't matter, in witch Directory ActiveX DLL is, because it is registered

- I found no Way, to instantiate the ActiveX in an Object Tag

- For 32 Bit and 64 Bit Versions of IE it is necessary to register the ActiveX with the Appropriate RegASM

© Willi Neuner 2019 Impressum