views:

34

answers:

2

When the Register for COM Interop option in the build properties is checked, I get an error:

Cannot register assembly -access denied

When the option is unchecked, the project builds without any error. But my requirement is to register the COM objects as I need to use the same in VB. Can anyone help me out in this?

+6  A: 

Under Windows Vista and higher, try to run Visual Studio elevated, so it has the permissions necessary to perform a regasm on your output assembly.

Frédéric Hamidi
Thanks, this solution worked for me.....
Kings
Then mark it as an answer :)
Kirill Muzykov
+2  A: 

An extension to Frédéric Hamidi's answer (upvote for your sir), you could either run Visual Studio as administrator, or turn off the 'register for COM interop', and open up a command prompt as the administrator.

The command to register the component is then something like this (on my machine - W7 64-bit):

c:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe /tlb /codebase C:\path\to\your\DLL

Personally I use the latter as the debugging process is quite complex and sometimes it's not possible to step through the code (or some of the debugging takes place on another machine)

mdm

related questions