我无法构建具有强名称密钥签名的项目-标题中的消息总是出现。

是的,项目最初是从另一台机器复制过来的。然而,即使我通过“项目属性”中的“签名”选项卡添加了一个新密钥,仍然会显示此错误。

我曾尝试以管理员身份运行Visual Studio,并尝试手动将密钥添加到Windows证书存储区。

的帮助!

编辑:我没有得到这个错误与一个新项目,但我很想让这个现有的项目工作。即使我创建了一个新的证书,它也不能工作!


当前回答

仅手动向Windows证书存储区添加密钥是不够的。证书只包含已签名的公钥。您还必须导入与证书中的公钥相关联的私钥。pfx文件在单个文件中包含公钥和私钥。这就是你需要导入的东西。

其他回答

转到visual studio中的项目“属性”。然后进入签名标签。

然后确保“签名单击一次”清单已关闭。

OR

1.在记事本中打开.csproj文件。

2.删除证书存储中与签名证书相关的如下信息 xxxxx xxxxxx xxxxxxxx.pfx 真正的 假 `

为我工作。

转到visual studio中的项目“属性”。然后进入签名标签。

然后确保“签名单击一次”清单已关闭。


更新说明:

在解决方案资源管理器中:

右键单击您的项目 点击属性 通常在左边,选择“Signing”选项卡 检查“签名点击一次”清单 确保你保存了!

如果您只需要在本地构建项目或解决方案,那么正如其他人建议的那样,删除签名可能是一个非常简单的解决方案。

但是,如果您在自动化构建服务器(如TeamCity)上有此错误,您可能需要考虑如何将此证书正确地安装到构建机器上的证书存储中,以便在构建结束时获得已签名的包。

通常情况下,不需要重新将任何PFX证书签入/提交到源代码控制中,因此在构建过程中如何在构建服务器上获得此文件是另一个问题,但有时人们确实将此文件与解决方案代码一起存储,因此您可以在项目文件夹中找到它。

您所需要做的只是在构建服务器上的适当帐户下安装此证书。

Download PsExec from Windows Sysinternals. Open a command prompt, and enter the following. It will spawn a new command prompt, running as Local System (assuming that your TeamCity is running under the default Local System account): > psexec.exe -i -s cmd.exe In this new command prompt, change to the directory containing the certificate and enter the filename to install (change the name of the file to yours): > mykey.pfx The Import Certificate wizard will start up. Click through and select all the suggested defaults. Run the build.

所有学分去斯图尔特高贵(然后进一步Laurent肯普我相信☺)。

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.

使用属性为具有强名称的程序集签名

打开AssemblyInfo.cs(在$(SolutionDir)\属性中)

AssemblyKeyFileAttribute或AssemblyKeyNameAttribute,指定文件或容器的名称,该文件或容器包含在使用强名称对程序集进行签名时使用的密钥对。

添加如下代码:

[assembly:AssemblyKeyFileAttribute("keyfile.snk")]