Register .NET assembly as COM component with REGASM

A

Andy Bates

Hi -

I have a C# .NET assembly that exposes a COM interface (basically has an
interface and class with Guid attributes).

If I compile this under VS.NET (with the "Register for COM Interop"
selected). Then I can import the TLB into C++ and use the component as a
standard COM component, it creates and I can call it's methods.

If however, I take the DLL and use REGASM to register the component. I
cannot use the component, the application reports that the class is not
registered (CreateInstance fails)!

Can anyone tell me what else I need to do in order to register the
component? VS.NET appears to be doing something else that is making the
component accessible!

I would also like to register the component from another .NET application
(without using REGASM). I believe the key to this is the RegistrationService
class, but I appear to be experiencing the same problem with this as the
REGASM problem above (i.e. class not registered)!

I have the following code, which incidently doesn't return any errors (or
throw any exceptions):

Assembly asm = Assembly.LoadFile (@"c:\temp\ImageConverter.dll");

RegistrationServices reg = new RegistrationServices ();

reg.RegisterAssembly (asm, 0);

Any help is greatly appreciated?

TIA

- Andy
 
M

Mattias Sjögren

Andy,
Can anyone tell me what else I need to do in order to register the
component? VS.NET appears to be doing something else that is making the
component accessible!

VS.NET effectively does the same as running RegAsm with the /codebase
option.

reg.RegisterAssembly (asm, 0);

Passing AssemblyRegistrationFlags.SetCodeBase as the second parameter
corresponds to /codebase.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top