【问题标题】:Cryptographic failure while signing assembly in Visual studio在 Visual Studio 中签署程序集时出现加密错误
【发布时间】:2010-11-21 08:41:38
【问题描述】:

我不知道我哪里出错了。当我构建它时,它会搜索 DLL 登录的默认路径。即使我指定了路径。

我已创建 .snk 文件并将其存储在与 DLL 相同的位置。

//Assembly info file for errorcollection

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ErrorCollection")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ErrorCollection")]
[assembly: AssemblyCopyright("Copyright ©  2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2c17131b-0ae3-4146-a797-308f5958e819")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyKeyFile(@"D:\Services\bin\ErrorCollection.snk")]

我收到以下错误:

"签名程序集'D:\Services\ErrorCollection\obj\Debug\ErrorCollection.dll'时加密失败--'读取密钥文件'D:\Services\bin\ErrorCollection.snk'时出错--系统找不到指定的文件。'ErrorCollection"

【问题讨论】:

  • snk 是否真的在 D:\Services\bin\ErrorCollection.snk 中?
  • 是的,我看到了。它正好位于我指定的位置。
  • 有没有解释为什么这个问题被关闭了?这样我就知道不应该发布什么。

标签: c# visual-studio dll


【解决方案1】:

检查本地机器上Keys文件夹的访问权限,给VS用户权限。

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

【讨论】:

  • 我遇到了同样的问题并以类似的方式解决了它,请参阅github.com/nosami/Omnisharp/issues/150
  • 完美结局。我已将所有者更改为该文件夹的本地组管理员,但忘记为他们添加权限。
【解决方案2】:

对我来说,这个问题是在升级到 Windows 10 后发生的。 然后,MachineKeys 的位置位于不同的位置,即

C:\ProgramData\Microsoft\Crypto\RSA

右键单击 MachineKeys 并确保设置了所有权限。

【讨论】:

  • 对于未来的读者......这个答案解决了我的问题。但我也遇到了“授予权限”问题....正如这个网址所见。 social.technet.microsoft.com/Forums/windowsserver/en-US/…
  • 您可能不会遇到授予权限的问题。但如果你这样做了,请按照我之前评论中的网址或互联网搜索短语“无法枚举容器中的对象。访问被拒绝”但是在我解决了实际授予权限的问题之后......这个答案节省了一天.
【解决方案3】:

路径必须是相对于程序集的。

请查看以下知识base

因此尝试改变

@"D:\Services\bin\ErrorCollection.snk"

类似于(这里我假设它是您的根 d 驱动器的四个级别)

@"..\..\..\..\Services\bin\ErrorCollection.snk"

【讨论】:

    【解决方案4】:

    尝试创建具有相同名称的新 snk 并覆盖旧的

    这对我有用。猜测 snk 以某种方式损坏了

    【讨论】:

      【解决方案5】:

      右键单击您的项目-->属性-->选中“签署程序集”

      【讨论】:

        【解决方案6】:

        为我解决的问题是确保我以管理员身份运行 Visual Studio。

        【讨论】:

          【解决方案7】:

          您也可以在您的visualstudio中停用登录

          【讨论】:

            【解决方案8】:

            以管理员身份运行打开 Visual Studio,解决了我的问题。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2011-11-14
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2017-09-19
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多