在为COM Interop构建.NET DLL时“访问注册表项被拒绝”

问题描述 投票:4回答:2

目标:在另一个环境中建立一个C# DLL with COM interop to be called by Delphi

问题:Windows阻止了我的构建,说我没有编辑注册表的权限。

语境:

  • 我正在使用Windows 8,Visual Studio 2012,UAC已关闭。
  • 我正在使用RGiesecke的DllExport使用[DllExport]注释我想要导出为Dll的方法。
  • 我正在使用[ComVisible(true)]作为建议here
  • 我的解决方案平台目标是x86
  • 我编辑了我的解决方案的构建属性并检查了qazxsw poi
  • 我由Build > Output > Register for COM Interop编辑并启用了AssemblyInfo.cs
  • 我用一个强有力的名字签署了我的集会

如果我作为管理员运行VS2012我得到这个错误:[assembly: ComVisible(true)]

也许我需要以管理员身份运行Visual Studio。但是,如果我作为管理员运行VS2012,我会得到另一个错误(甚至更随机):Cannot register assembly 'absolute\path\to\NameOf.dll' access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOT\NameOf.DllClass' is denied

我按照Cannot register assembly. Could not load file or assembly 'RGiesecke.DllExport.Metadata, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad5f9f4a55b5020b' or one of its dependencies. The system cannot find the file specified.的步骤,即查找和更改FIX: "Access to the Registry Key Denied" Error Message When You Register .NET Assembly for COM Interop的权限。没运气。

如何获得构建我的DLL并获取HKEY_CLASSES_ROOT\Component Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}文件所需的权限?

c# delphi visual-studio-2012 dll com-interop
2个回答
5
投票

我也有同样的问题。我也没有设法解决你在问题中提到的链接。但我确实有一个解决方法。如果以管理员身份打开Visual Studio,那么一切都有效(至少对我而言)。


0
投票

我遇到了同样的问题,我能够解决它打开注册表编辑器,转到错误提到的密钥。右键单击并选择“权限...”。我确保我的计算机的所有用户(因为它是工作计算机)具有完全权限。保存,现在它可以正常工作,没有错误。

© www.soinside.com 2019 - 2024. All rights reserved.