Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register a C#/VB.NET COM dll programmatically

Question: I have a .NET dll which I use from a C++ program. Now I have to register the dll programmatically on a deployment computer.

How do I do that (programmatically! not using regasm)? I remember, when I once called a VB6 dll from a C++ dll, I had to use DllRegisterServer and DllUnregisterServer.

Is that still so with a .NET dll?
It seems I have to somehow add the dllregisterserver function to the .NET dll.

like image 523
Stefan Steiger Avatar asked Mar 04 '10 11:03

Stefan Steiger


People also ask

Should I use register C?

Registers are faster than memory to access, so the variables which are most frequently used in a C program can be put in registers using register keyword. The keyword register hints to compiler that a given variable can be put in a register. It's compiler's choice to put it in a register or not.

What is register value in C?

Register variables tell the compiler to store the variable in CPU register instead of memory. Frequently used variables are kept in registers and they have faster accessibility. We can never get the addresses of these variables. “register” keyword is used to declare the register variables.

When should the register modifier be used?

When should the register modifier be used? Does it really help? The register modifier hints to the compiler that the variable will be heavily used and should be kept in the CPU's registers, if possible, so that it can be accessed faster.

What is register in embedded C?

Many devices have multiple internal registers, but only respond to a single address. To access a specific register, the code first needs to write the register number to the device and then perform the required write/read operation. This is not difficult, but needs to be managed carefully.


1 Answers

YUK, .NET dlls don't have DllRegisterServer, so you have to write a .NET installer, executing this somewhere:

Assembly asm = Assembly.LoadFile (@"c:\temp\ImageConverter.dll");
RegistrationServices regAsm = new RegistrationServices();
bool bResult = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
like image 169
Stefan Steiger Avatar answered Sep 23 '22 22:09

Stefan Steiger