I found a great tutorial which shows how to create and deply a COM object here, but it needs a slight change to make it an ActiveX control.
You'll notice that in the tutoril there is a line that says:
[ClassInterface(ClassInterfaceType.None)]
which you should change to:
[ClassInterface(ClassInterfaceType.AutoDual)]
Also, the tutorial didn't clearly explain the build steps, so I will clarify them. Open up the Visual Studio Command Prompt (it basically sets some environment vars) and then do the following:
> csc /t:library yoursource.cs
> Tlbexp yoursource.dll
Go ahead and create your setup and deployment project as per the tutorial, but note that you must use Visual Studio 2005 as 2003 does not do it properly.
[edit]
Actually, that does't seem to work properly either, so here is what I have decided is the sure-fire way to make it work:
You'll need a tool like RegShot, or RegMon which will allow you to see the differences before/after registering your dll. Make sure your registry is clean (specifically if you have had the dll installed and running, trawl through and remove every trace of it). Next, take a snapshot of your registry (using your choice of tool from above), then open the Visual Studio Command Prompt and go to the folder where you built your dll before and type:
> regasm /tlb:yoursourceTLB.dll yoursource.dll /codebase
Then go and take another snapshot of your registry and use your tool to tell you which keys were added. Use regedit to go and export those keys, and then forcibly import those keys into your setup and deployment project. Also, add yoursourceTLB.dll to your S&D project, and remember to set all your dll's/tlb's not to be registerd by your installer. This will work better
[/edit]
No comments:
Post a Comment