views:

595

answers:

4

I have developed a C# com component which I am using from managed c++. On my dev machine when everything works fine. However when I distribute the files, I received an error that the component has not been registered. When I try a regsvr32 on the dll it gives me an error (C# dlls cannot be registered). How do I properly register this COM dll?

+2  A: 

You use regasm with /codebase (and it needs to be ComVisible [but as Patrick McDonald correctly poinhts out, you've already got past that as it works locally])

Ruben Bartelink
It must already be ComVisible if it works on Dev machine, +1 for regasm
Patrick McDonald
A: 

Use the Assembly Registration Tool (Regasm.exe)

Mitch Wheat
A: 

Use RegAsm with siwtch /codebase if your assembly is not installed in the GAC (Global Assembly Cache).

Details of further switches is here

Aamir
A: 

I find that you normally need to do:

regasm /codebase

Because COM needs to know the exact location of your assembly to be able to load it.

As others have suggested, you will need to set you C# project as COM visible (project settings, application, assembly information button).

Finer control of which classes are visible or not can be obtained using the [ComVisible(true)] / [ComVisible(false)] attribute before each class

John Sibly