Discussion:
Call managed dll from unmanaged code fails in Windows 7
(too old to reply)
MacDermott
2010-01-27 01:29:04 UTC
Permalink
Raw Message
I have an activex dll I wrote in vb.net, and want to call from VBA behind
Access.
I register it on the target machine using RegAsm.
This works fine under Windows XP,
but fails with "ActiveX cannot create object" under Windows 7.

Any ideas?
- Turtle
Jason Keats
2010-01-27 14:25:13 UTC
Permalink
Raw Message
Post by MacDermott
I have an activex dll I wrote in vb.net, and want to call from VBA behind
Access.
I register it on the target machine using RegAsm.
This works fine under Windows XP,
but fails with "ActiveX cannot create object" under Windows 7.
Any ideas?
- Turtle
My guess is that you're supposed to right-click the Visual Studio
Command Prompt menu item, select Run As Administrator, then try using
regasm.

Or, you could probably create a batch file to do what you want, then run
it as administrator.

You should probably also take care to compile as 32-bit, ie don't use
Any CPU (especially if running on 64 bit O/S).
MacDermott
2010-01-28 01:53:15 UTC
Permalink
Raw Message
Thanks so much for your ideas, Jason!

Visual Studio is not installed on my target machine,
so I don't think there is a "Visual Studio Command Prompt menu item"
available.
However, the lone user on that machine has all administrator rights.
But if my DLL appears in the References Dialog,
isn't that pretty good evidence that Regasm has registered it properly?

The DLL is certainly compiled as 32-bit -
I don't do anything in the 64-bit world.

I would welcome more ideas/insights.
- Turtle
Post by MacDermott
I have an activex dll I wrote in vb.net, and want to call from VBA behind
Access.
I register it on the target machine using RegAsm.
This works fine under Windows XP,
but fails with "ActiveX cannot create object" under Windows 7.
Any ideas?
- Turtle
My guess is that you're supposed to right-click the Visual Studio Command
Prompt menu item, select Run As Administrator, then try using regasm.
Or, you could probably create a batch file to do what you want, then run
it as administrator.
You should probably also take care to compile as 32-bit, ie don't use Any
CPU (especially if running on 64 bit O/S).
Jason Keats
2010-01-28 10:03:56 UTC
Permalink
Raw Message
Post by MacDermott
Thanks so much for your ideas, Jason!
Visual Studio is not installed on my target machine,
so I don't think there is a "Visual Studio Command Prompt menu item"
available.
However, the lone user on that machine has all administrator rights.
But if my DLL appears in the References Dialog,
isn't that pretty good evidence that Regasm has registered it properly?
The DLL is certainly compiled as 32-bit -
I don't do anything in the 64-bit world.
I would welcome more ideas/insights.
- Turtle
What does your ActiveX do?

Is it trying to run a program/dll/object that doesn't exist on the
target machine?

In other words, have you installed all dependencies?

What sort of error handling are you using? Could it be improved so that
it gives you a better idea of what is causing the problem?
Craig Berntson
2010-01-28 15:44:38 UTC
Permalink
Raw Message
The registration must be run under elevated privilege. Instead of just
running a command window they need to right-click on the Start menu entry
for it and select "Run as administrator". Then, when you run RegAsm, they
have the elevated privilege needed. Yes, they need to do this even if they
are an Administrator.
--
----
Craig Berntson
Microsoft MVP
Post by MacDermott
I have an activex dll I wrote in vb.net, and want to call from VBA behind
Access.
I register it on the target machine using RegAsm.
This works fine under Windows XP,
but fails with "ActiveX cannot create object" under Windows 7.
Any ideas?
- Turtle
Loading...