How to Register a .Net Com Dll with Regsvr32

How do I register a .NET COM DLL with Regsvr32?

You can't. Managed [ComVisible] class libraries need to be registered with Regasm.exe.

You can do it from the IDE with Project + Properties, Build tab, Register for COM interop checkbox. If you run Regasm.exe you usually want the /codebase command line option so you don't have to put the assembly in the GAC. Yet another option is to let Regasm.exe generate a .reg file with the /regfile option. You'd just run that on the target machine to get the registry updated.

Edit: just saw the "major problems" remark. Note sure what they are, short from /codebase. You do have to pick the right version on 64-bit machines. There are two. And you need an elevated command prompt so that UAC don't put a stop to it.

How to create library that can register with regsvr32?

You can read through these:

A Beginner Tutorial for Writing Simple COM/ATL DLL For VS2012

A Beginner Tutorial for Writing Simple COM/ATL DLL and Using it with .NET

C# COM DLL: do I use Regasm, or Regsvr32?

You need to use regasm.exe to register both the 32 bit and 64 bit interfaces I believe you need to run each of the regasm.exe's in:

C:\Windows\Microsoft.NET\Framework\v2.0.50727

and

C:\Windows\Microsoft.NET\Framework64\v2.0.50727

So... in your case you need to run the regasm.exe in the Framework64\v2.0.50727 folder.

Here's an example we use to register a COM interop DLL for one of our legacy ASP apps:

regasm.exe Hosting.DeviceManager.Power.dll /register /codebase /tlb

Do I need to register the COM dll to be able to reference it on the .NET project?

you need to register dll. you can set registration in your setup project or create a batch file for all these type of processes.
Note: Don't forget to unregister dll on uninstallation.

Unable to register the C# dll as a COM Component, The module was loaded but the entry-point DLLRegisterServer was not found

To register a .NET DLL, you need to use Regasm.exe instead of regsvr32.exe. Regasm.exe is located in C:\Windows\Microsoft.NET\Framework\v4.0.30319 (or similar depending on .NET version).

Also make sure to specify the /codebase option, or make the assembly strongly-named, otherwise COM won't be able to find the DLL.

Registering DLLs and .TLBs

If you are talking about installing COM DLLs in the System folder, then you are correct. All applications, and their support libraries, should be installed under the Program Files folders, or the Common Program Files folders.

You are also correct that REGSVR32.EXE can be used to manually register DLLs and OCX. "Foreign folder" is not a Windows concept - you can register a component anywhere in the file system, including the Windows and Windows System folders. By the way, if you use an installer, then you shouldn't have to use REGSVR32.EXE.

However, TLB files cannot be registered with REGSVR32.EXE, because that application basically loads the DLL/OCX, and calls an exported function on the library, so effectively the library registers itself. Instead, you need another tool, e.g. REGTLIB.

You don't use /CODEBASE to register a raw type library, because REGASM is used for registering .NET DLLs as COM components, not TLB files.



Related Topics



Leave a reply



Submit