0

I have a VB.Net project which needs to use a third party DLL for which there also an interop assembly. So I have something like this:

Hummingbird.DM.Server.Interop.PCDClient.dll
PCDClient.dll

I tried adding the reference to the interop directly in the project, but on running the file I got a COM not registered error.

So, I tried registering the interop as follows:

gacutil /if "C:\....\Hummingbird.DM.Server.Interop.PCDClient.dll"

regasm "C:\....\Hummingbird.DM.Server.Interop.PCDClient.dll"

Even after restarting VS, the assembly is still not visible.

Jahan Zinedine
  • 14,616
  • 5
  • 46
  • 70
udeleng
  • 157
  • 5

2 Answers2

1

Your regasm command destroyed the registry keys for the COM server. You'll have to reinstall it. Only use regasm on your own [ComVisible] code.

One reason you may have trouble using the component, beyond it just not having been installed correctly, is because you are trying to run this on a 64-bit operating system. And the component is 32-bit, by far the most common case. You need to force your app to run in 32-bit mode to be able to use it. In the VB.NET IDE, that's done with Project + Properties, Compile tab, scroll down, Advanced Compile Options, set Target CPU to "x86".

The ultimate troubleshooting tool for problems like this is SysInternals' ProcMon utility. It shows you how COM is using the HKLM\Software\Classes\CLSID key to search for the DLL to load.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • So you're saying I should only use GACUTIL, and not both? I unregistered it using "regasm /u ...", then I did "gacutil /if ..." is this sufficient? My system is Win XP 32Bit. – udeleng Jan 14 '11 at 17:20
  • You should use neither, this COM server isn't likely to be managed code. As I said, running regasm overwrote the registry keys for the COM server, you have to re-install it. Using Regsvr32 on the *unmanaged* DLL (not the interop library) is the likely way, do ask for support from the vendor if you have more trouble. – Hans Passant Jan 14 '11 at 17:40
  • I used "regsvr32 PCDClient.dll" (the interop is still in GAC, not sure if that's needed), and now I see Interop.PCDCLIENTLib listed in Object Browser. Can you confirm that the steps I should use are: gacutil /if "C:\...\Hummingbird.DM.Server.Interop.PCDClient.dll" regsvr32 "C:\...\PCDClient.dll" – udeleng Jan 14 '11 at 17:51
  • Do not use gacutil. Just adding the pcdclient.dll as a reference is enough to get the interop library in your build directory (bin\Debug). – Hans Passant Jan 14 '11 at 17:56
0

You're registering the interop, but (as the error message suggests) you've not registered the COM DLL. Try this:

regsvr32 pdcclient.dll
Dan Puzey
  • 33,626
  • 4
  • 73
  • 96