Register for COM Interop

荒凉一梦 提交于 2021-02-07 03:06:26

问题


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?


回答1:


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)




回答2:


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.



来源:https://stackoverflow.com/questions/3996813/register-for-com-interop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!