3

I have written a C# .NET Com callable wrapper DLL. I signed it with a StrongName and registered the codebase and typelib with the 64 bit regasm.exe. The registration and all the control's methods are visible with the 64-bit OleViewer. However, when I try to use the control from 64 bit \Windows\System32\cscript.exe:

  Set logger = CreateObject("MyCompany.LoggerControl")

This produces the error:

Microsoft VBScript runtime error: ActiveX component can't create object: 'MyCompany.LoggerControl'

Using ProcMon from Sysutils to track this down, I find:

1:41:44.8295486 PM cscript.exe 24028 RegOpenKey HKCR\MyCompany.LoggerControl
NAME NOT FOUND Desired Access: Read

However, this key exists in Regedit. The calling process is running from an elevated command prompt. If it was a security problem, shouldn't the error be 'ACCESS DENIED' instead of 'NAME NOT FOUND'?

What are other tools to track down this type of COM control registration error?

Mike
  • 1,276
  • 4
  • 16
  • 27
  • 1
    Is there such "HKCR\MyCompany.LoggerControl" and can it be accessed? Make sure to look from the *same bitness* regedit, and double-check the bitness of the executing program, just to make sure something funky didn't happen. (A "*" suffix in the Task Manager = 32-bits.) –  Mar 08 '12 at 19:11

1 Answers1

1

Here are a couple of troubleshooting ideas:

  1. Identify the exact error number being returned when trying to create the object:

    On Error Resume Next
    Set logger = CreateObject("MyCompany.LoggerControl")
    If Err Then WScript.Echo "Error # " & Err.Number WScript.Echo Err.Description WScript.Quit 1 End If

  2. Look up this error code. For example, is it "access denied" or some other error?

  3. Create a C# executable to call your object and see if it can sucessfully create it.

  4. Make sure your DLL doesn't have any other dependencies that prevent it from being loaded in the directory your script runs. You can use depends.exe from the directory your are running your script from or you can use my favorite poor man's technique of regsvr32 to try and load the DLL. If the DLL fails to load due to a dependency you will get an error dialog telling you it can't find another DLL or load one of its dependencies. If it can load the DLL ok it will say it successfully registered it.

    C:\PathToVbs>regsvr32 C:\PathToYourDLL\YourDLL.dll

kennbrodhagen
  • 4,258
  • 2
  • 26
  • 21
  • Update - I found my problem - despite double and triple checking, I had misspelled the company name, so the original ProcMon trace was correct - the name was not found. – Mike Mar 08 '12 at 19:35