Registering a COM object created with VS C# 2010

deutschZuid picture deutschZuid · Jul 12, 2011 · Viewed 10k times · Source

I created a COM object with C# yesterday which resulted in three files in the bin/release directory of my VS 2010 project (comclass.dll, comclass.pdb and comclass.tlb). Now, when I build the solution in the project, VS registers the class for me automatically on the development PC and I have no problem accessing the COM object and its methods from, let's say, Powershell. However, when I copy the three files onto a different machine and try to register the dll with regsvr32, it tells me that

the module "comclass.dll" was loaded but the entry-point DllRegisterServer was not found.

Make sure that "comclass.dll" is a valid DLL or OCX file and then try again.

Using regasm with the /tlb parameter on the .tlb file gives me a similar message. So I am a little bit stumped. Anyone knows how I should proceed from here?

Answer

Joel B Fant picture Joel B Fant · Jul 12, 2011

Just copy the dll (and optionally the pdb if you want file paths and line numbers in your stack traces). This is how you register it, and the tlb is created:

"%WINDIR%\Microsoft.NET\Framework\v2.0.50727\regasm.exe" comclass.dll /tlb /nologo /codebase

Since Visual Studio successfully registers it, that might just work. If not, you could also open the Output panel while doing a Rebuild and see how Visual Studio calls regasm.