Windows XP
(1)
Visual Studio
(1)
Windows 7
(1)
VBA
(1)
Dialog
(1)
Regasm
(1)
Activex
(1)

Call managed dll from unmanaged code fails in Windows 7

Asked By MacDermott
26-Jan-10 08:29 PM
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

MacDermott wrote:My guess is that you are supposed to right-click the Visual

Jason Keats replied to MacDermott
27-Jan-10 09:25 AM
My guess is that you are 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 do not use
Any CPU (especially if running on 64 bit O/S).

Thanks so much for your ideas, Jason!

MacDermott replied to Jason Keats
27-Jan-10 08:53 PM
Thanks so much for your ideas, Jason!

Visual Studio is not installed on my target machine,
so I do not 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,
is not that pretty good evidence that Regasm has registered it properly?

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

I would welcome more ideas/insights.
- Turtle

MacDermott wrote:What does your ActiveX do?

Jason Keats replied to MacDermott
28-Jan-10 05:03 AM
What does your ActiveX do?

Is it trying to run a program/dll/object that does not 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?
The registration must be run under elevated privilege.
Craig Berntson replied to MacDermott
28-Jan-10 10:44 AM
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 Question To EggHeadCafe