我无法构建具有强名称密钥签名的项目-标题中的消息总是出现。
是的,项目最初是从另一台机器复制过来的。然而,即使我通过“项目属性”中的“签名”选项卡添加了一个新密钥,仍然会显示此错误。
我曾尝试以管理员身份运行Visual Studio,并尝试手动将密钥添加到Windows证书存储区。
的帮助!
编辑:我没有得到这个错误与一个新项目,但我很想让这个现有的项目工作。即使我创建了一个新的证书,它也不能工作!
我无法构建具有强名称密钥签名的项目-标题中的消息总是出现。
是的,项目最初是从另一台机器复制过来的。然而,即使我通过“项目属性”中的“签名”选项卡添加了一个新密钥,仍然会显示此错误。
我曾尝试以管理员身份运行Visual Studio,并尝试手动将密钥添加到Windows证书存储区。
的帮助!
编辑:我没有得到这个错误与一个新项目,但我很想让这个现有的项目工作。即使我创建了一个新的证书,它也不能工作!
当前回答
试试这个:
右键点击你的项目→转到属性→点击屏幕左侧的签名→取消选中签名,单击一次显示→保存和构建
其他回答
你说你从另一台电脑上拷贝了文件。在你复制它们之后,你是否“解锁”了它们?具体来说,应该检查.snk文件,以确保它没有被标记为不安全。
使用属性为具有强名称的程序集签名
打开AssemblyInfo.cs(在$(SolutionDir)\属性中)
AssemblyKeyFileAttribute或AssemblyKeyNameAttribute,指定文件或容器的名称,该文件或容器包含在使用强名称对程序集进行签名时使用的密钥对。
添加如下代码:
[assembly:AssemblyKeyFileAttribute("keyfile.snk")]
在记事本中打开.csproj文件。 删除证书存储中与签名证书相关的如下信息 < PropertyGroup > < ManifestCertificateThumbprint > xxxxx xxxxxx < / ManifestCertificateThumbprint > < ManifestKeyFile > xxxxxxxx.pfx < / ManifestKeyFile > 真正< GenerateManifests > < / GenerateManifests > 假< / SignManifests < SignManifests > > < / PropertyGroup >
我终于找到解决办法了。
编辑项目的.csproj文件。 删除以下代码行: < PropertyGroup > < ManifestCertificateThumbprint >...........</ ManifestCertificateThumbprint > < / PropertyGroup > < PropertyGroup > < ManifestKeyFile > xxxxxxxx.pfx < / ManifestKeyFile > < / PropertyGroup > < PropertyGroup > 真正< GenerateManifests > < / GenerateManifests > < / PropertyGroup > < PropertyGroup > 假< / SignManifests < SignManifests > > < / PropertyGroup >
Assuming this is a personal certificate created by windows on the system you copied your project from, you can use the certificate manager on the system where the project is now and import the certificate. Start the certificate manager (certmgr) and select the personal certificates then right click below the list of existing certificates and select import from the tasks. Use the browse to find the .pfx in the project (the .pfx from the previous system that you copied over with the project). It should be in the sub-directory with the same name as the project directory. I am familiar with C# and VS, so if that is not your environment maybe the .pfx will be elsewhere or maybe this suggestion does not apply. After the import you should get a status message. If you succeeded, the compile certificate error should be gone.