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?
Here are a couple of troubleshooting ideas:
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
Look up this error code. For example, is it "access denied" or some other error?
Create a C# executable to call your object and see if it can sucessfully create it.
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