web installation of ActiveX written in C#; Can't register DLL

RandyTommy
RandyTommy used Ask the Experts™
on
I found a simple article on making an ActiveX that includes input/output parameters.  Exactly the structure I need. It is located at:
http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx

But it won't work from Javascript without being Registered in the system.  A Microsoft article at:
http://support.microsoft.com/kb/280579
states "The ActiveX control must be packaged as an Installer Package (.msi) file instead of as a standard Internet Explorer cabinet (.cab) file."
So I downloaded the free MakeMSI program and spent the day learning to use it.  However, while installing the .msi file it created, I got an error message that
my DLL could not be installed.

As a test, I tried installing the DLL by hand, which gave me the error message that the "dllregisterserver entry point was not found."
Googling the term "dllregisterserver", I found:
http://msdn.microsoft.com/en-us/library/dd376682(v=vs.85).aspx
which explains how to include it in C++ DLLs.  However, I'm using C#, which can't find either "STDAPI" nor "AMovieDllRegisterServer2", essential parts of the example shown.

I've been unable to find any information on doing this in C#.  So I'm totally lost at this point.

Maybe all the above isn't really the best way?  Going back to the beginning, my basic question is still, how can I write ActiveX's in C# that can be installed in client machines from my website?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Architect
Commented:
If you want your .NET assembly to be callable by COM clients you have to decorate it with some attributes so the COM subsystem is able to register it.

In the AssemblyInfo file you need a line like the following:

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid( "fa6c3201-35bd-413a-89a6-42ce80037c25" )]

Generate your own GUID, don't re-use that one.

Then you should create an interface to represent the class you're exposing to COM. On that interface add the following attributes:

    [ComVisible( true )]
    [Guid( "50d74b13-15d9-4770-b773-c968666620d5" )]
    [InterfaceType( ComInterfaceType.InterfaceIsDual )]

Again, generate your own GUID, don't reuse that one.

Finally, on the class that implements the interface, add the following attributes:

    [ComVisible( true )]
    [Guid( "6db34b66-c7a2-492b-95f5-7fd44c833cc0" )]
    [ClassInterface( ClassInterfaceType.None )]
    [ProgId( "My.ProgId" )]

Again, generate a new GUID. The ProgId how your COM clients will create your object, so make it somewhat meaningful (e.g. Office.Excel, MyCompany.Security, etc).

This article may help fill in the blanks.

http://www.simple-talk.com/dotnet/visual-studio/build-and-deploy-a-.net-com-assembly/

Author

Commented:
Thank you for the detailed, step-by-step answer.  That's information worth keeping!  Although in my case, I'm attempting to steer away from making a website depend on .NET.  So I'm still looking for a siimple answer.  I did find two pages that addressed my "install dll" problem, stating simply "You can't do it".  Not my way at least. Success would require YOUR way.  :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial