views:

218

answers:

2

I wrote an assembly in C# and I needed to invoke a method on the DLL from a VB6.0 application. I made the DLL COM compliant and registered the DLL accordingly. From my VB application I would then instantiate the class in the .NET assembly using the VB6.0 CreateObject method.

Set dotNetObj = CreateObject("Namespace.ClassName")

I would then be able to invoke any method on that class.

The Problem:

All worked fine, until I tried executing the code on a Vista machine. Whenever I execute the exe it works fine, but whenever the exe is executed using the 'run as administrator' option the following error appears:

"ActiveX component can`t create object."

I need this EXE to run in admin mode, else certain areas of the legacy system won't work.

Any ideas on why the CreateObject would not work in admin mode?

+1  A: 

It sounds like maybe the COM component is only registered for the user - so when the admin tries it, the clsid is unknown. Try running your isntallation/registration process for the admin.

(does vista put clsids in HKCU? or just HKLM?)

A quick search seems to indicate that it relates to whether UAC is enabled or disabled... with it enabled it looks in HKCU... disabled and it looks in HKLM. So if you are installing into HKCU, it won't be there for an admin with UAC disabled.

Marc Gravell
I just needed to toggle the InstallAllUsers property to TRUE in my package and deployment software.
MegaByte
A: 

Because it is only registered in the user space?

Try to register your dll in an admin shell

regasm mycomponent.dll /register /codebase /tlb

Vinzz
For a .NET dll, it is more likely to be regasm or similar...
Marc Gravell
even if it's COM compliant? You may be right, I'll check that
Vinzz
Yep, you're right, I'll modify my answer
Vinzz