关于VS2008+Win7出现error MSB3216: Cannot register assembly

Win7环境下,VS2008+ArcEngine9.3,在项目中,新建类库,但在项目进行编译时出现了错误:

MyGISClassLib -> D:/Project/MSProject/MyGIS/MyGISClassLib/bin/Debug/MyGISClassLib.dll
C:/Windows/Microsoft.NET/Framework/v3.5/Microsoft.Common.targets(3019,9): error MSB3216: Cannot register assembly "D:/Project/MSProject/MyGIS/MyGISClassLib/bin/Debug/MyGISClassLib.dll" - access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOT/MyGISClassLib.ControlsSynchronizer' is denied.
Done building project "MyGISClassLib.csproj" -- FAILED.

 

类库编译不通过,MSDN论坛解决方案:

 

Hello

Regsvr32, Regasm, and the registration method used by Visual Studio do not give the choice to register COM per-user because they have no per-user or per-system context, so they have to be elevated to register the component.

A possible workaround is to add a MSI setup project. An MSI setup can choose per-user or per-system because there is infrastructure that supports it at install time and gives the installing user a choice.

1. uncheck the Register for COM interop option.
2. add a setup project (Other Project Types / Setup and Deployment / Setup Project)
3. Right-click the Setup project, select Add / Project Output / Primary output of your COM project.
4. Select Primary output of your COM project in the Solution Explorer, and display its properties. Set the Register property to be vsdrpCOM.
5. By default, the setup project always gives the UAC dialog, even though you install it per user. To turn off UAC compilance, you need to use Orca, a tool provided by Windows SDK.
6. After you install and launch Orca, open the resulting msi file.
7. In the View menu, select Summary Information, and uncheck the UAC Compilant option.
8. Save and close Orca
9. Run the setup project. Change the installation folder from the default C:/Program Files/... to a folder that is not restricted by UAC.

Please let me know whether this works for you.

Another option:

1. still uncheck the Register for COM interop option.
2. instead of using a msi setup project, use a .reg file to register COM component to per-user profile. You can prepare a .REG file with all needed regsitry keys for the COM component. Next, import regsitry by using the REG.exe tool:

reg.exe import <your reg file>

 

我并未完全按照这九步执行,我只是将类库项目右键->Properities->Build中的Register for COM interop选项去掉即可编译通过,目前还没有其它问题。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值