VS2012.NET 4.0 Clickonce VSTO Cryptographics异常:无法为提供的签名算法创建SignatureDescription

VS2012.NET 4.0 Clickonce VSTO Cryptographics异常:无法为提供的签名算法创建SignatureDescription,.net,visual-studio-2010,c#-4.0,clickonce,visual-studio-2012,.net,Visual Studio 2010,C# 4.0,Clickonce,Visual Studio 2012,我有一个VS2010.NET 4.0 VSTO Outlook加载项项目,我希望将其迁移到VS2012(但保留在.NET 4.0中)。它可以很好地编译,并且可以从IDE内部运行,但是当我尝试运行已发布的ClickOnce安装程序时,会出现以下异常: System.Deployment.Application.InvalidDeploymentException:异常 正在从中读取清单file://MyPath/MyAddIn.vsto: 舱单上可能没有 必须是有效的,否则无法打开文件。 --->

我有一个VS2010.NET 4.0 VSTO Outlook加载项项目,我希望将其迁移到VS2012(但保留在.NET 4.0中)。它可以很好地编译,并且可以从IDE内部运行,但是当我尝试运行已发布的ClickOnce安装程序时,会出现以下异常:

System.Deployment.Application.InvalidDeploymentException:异常 正在从中读取清单file://MyPath/MyAddIn.vsto: 舱单上可能没有 必须是有效的,否则无法打开文件。 --->System.Deployment.Application.InvalidDeploymentException:清单XML签名无效。 --->System.Security.Cryptography.CryptographyException:无法为签名算法创建SignatureDescription 供应

根据我的测试和在线研究(和),似乎只是在我的机器上安装了VS2012(无论我是从VS2010还是VS2012发布),就迫使ClickOnce安装程序在使用.NET 4.0时需要SHA1证书。当使用VS2010(未安装VS2012)编译时,我现有的SHA256证书在.NET 4.0中运行良好

  • 我无法将客户端升级到.NET4.5,因为这是一个VSTO40项目(在XP/Office2007上运行)
  • 我无法在本地计算机上卸载VS2012/.NET 4.5,因为我还有其他项目需要它
  • 我不能轻易地将我的证书从SHA256降级到SHA1

是否还有其他建议可以让我继续前进?

我通过创建一个新证书来解决问题,该证书用于对ClickOnce清单进行签名,并使用SHA1算法生成。您可以在此处看到对话:

编辑2014-8-05:
Visual Studio 2013更新3最终解决了此问题。

从固定问题->常规:

您甚至可以为应用程序使用SHA 256代码签名证书 目标是.NET Framework 4.0或更早版本。在此之前 更新后,.NET Framework 4.5必须出现在客户端上 将SHA 256代码签名证书用于桌面时的计算机 使用ClickOnce或Visual Studio工具发布的应用程序 Office插件。如果在中使用了SHA 256代码签名证书 过去,并已看到错误,如“应用程序不正确 已格式化、“清单可能无效”、“清单XML签名” 无效,无法为创建“或”签名说明 提供的签名算法“此更新解决了 重新发布和新发布的应用程序


与Visual Studio 2012 RTM相同。当我在干净的Windows 7 ultimate机器上部署应用程序时,我遇到了“无法为提供的签名算法创建SignatureDescription”异常。
在部署计算机上安装.Net Framework 4.5后解决的问题

我收到了完全相同的错误消息,当时正在使用VS 2013、.NET 4.5,并使用SHA256正确地签署所有内容


最后,我发现安装了一个较旧版本的VSTO 2010运行时(10.0.40303)。一旦我们更新了它,一切都很好。我真的希望这能帮上忙,好几天来我都想弄清楚到底发生了什么。编辑:我后来发现重新签名是唯一能让这一切成功的东西。忽略下面关于更改.Net版本的内容


我是在一个VSTO项目中遇到这个问题的,当时我使用Visual Studio 2015发布,目标是.Net 4.5,并在客户机上运行.Net 4.5。理论上我不应该看到错误,但我发现应用程序清单(*.dll.manifest)仍在指定.Net 4.0。它在登录后第一次运行时就可以正常工作,但之后每次都会失败

<dependency>
  <dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
    <assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="4.0.30319.0" />
  </dependentAssembly>
</dependency>

. 这里有一个PowerShell脚本,我曾经这样做过。它将用完
应用程序文件\
文件夹

# get files only, no directories
$withDeploy = ls -Recurse | where Mode -eq "------" | where Name -Like "*.deploy"

if ($withDeploy.Length -gt 0)
{
    # rename .deploy files
    $withDeploy | %{ Rename-Item -Path $_.FullName -NewName $_.FullName.Replace(".deploy", "") }

    $certPath = "Z:\path\to\your\cert\file"
    $certFile = "$certPath\cert.p12"
    $certPass = "<your_password>"

    # re-sign the application manifest; should be <application>*.dll.manifest
    $manifestFile = ls | where Name -like "*.dll.manifest" | %{ return $_.Name }
    mage -Update $manifestFile -CertFile $certFile -Password $certPass

    # re-sign the deployment manifest; *.vsto
    $vstoFile = ls | where Name -like "*.vsto" | %{ return $_.FullName }
    #mage -Update $vstoFile -AppManifest $manifestFile -CertFile $certFile -Password $certPass

    $otherVstoFile = ls "..\..\" | where Name -like "*.vsto" | %{ return $_.FullName }
    mage -Update $otherVstoFile -AppManifest $manifestFile -CertFile $certFile -Password $certPass
    Copy-Item $otherVstoFile $vstoFile

    # put .deploy back
    $withDeploy | %{ Rename-Item -Path $_.FullName.Replace(".deploy", "") -NewName $_.FullName }
}
#仅获取文件,不获取目录
$withDeploy=ls-Recurse | where Mode-eq“-----”where Name-Like“*.deploy”
如果($withDeploy.Length-gt 0)
{
#重命名。部署文件
$withDeploy |%{Rename Item-Path$u.FullName-NewName$u.FullName.Replace(“.deploy”,”)}
$certPath=“Z:\path\to\your\cert\file”
$certFile=“$certPath\cert.p12”
$certPass=“”
#重新签署应用程序清单;应为*.dll.manifest
$manifestFile=ls |其中名称类似“*.dll.manifest”|%{return$|.Name}
mage-更新$manifestFile-证书文件$CertFile-密码$certPass
#重新签署部署清单;*.vsto
$vstoFile=ls |其中名称类似“*.vsto”|%{return$|.FullName}
#mage-更新$vstoFile-应用清单$manifestFile-证书文件$CertFile-密码$certPass
$otherVstoFile=ls“.\..\”|其中名称类似“*.vsto”|%{return$\.FullName}
mage-更新$otherVstoFile-AppManifest$manifestFile-CertFile$CertFile-Password$certPass
复制项目$otherVstoFile$vstoFile
#放回去
$withDeploy |%{Rename Item-Path$\.FullName.Replace(“.deploy”,”)-NewName$\.FullName}
}

理想情况下,最好对VisualStudio项目进行更改,这样我就不必每次发布时都这样做,但我看不到这样做的方法,任何解决方案都比没有解决方案好。我可能会将其添加为发布后MSBuild操作或其他操作,但目前它仍然有效。

有趣的是,您说您必须“安装”.NET 4.5,而我必须“卸载”.NET 4.5。是的,我必须在部署(客户)计算机中安装.NET 4.5。我认为.NET4.5有不同的方法来验证clickonce清单签名。如果我发布的应用程序没有签名,那么即使没有在部署(客户)机器中安装.NET4.5,所有的工作都正常。哦,我明白了。我还以为你在说你的机器呢。我的问题发生在ClickOnce调用阶段。我不是在编译wi
# get files only, no directories
$withDeploy = ls -Recurse | where Mode -eq "------" | where Name -Like "*.deploy"

if ($withDeploy.Length -gt 0)
{
    # rename .deploy files
    $withDeploy | %{ Rename-Item -Path $_.FullName -NewName $_.FullName.Replace(".deploy", "") }

    $certPath = "Z:\path\to\your\cert\file"
    $certFile = "$certPath\cert.p12"
    $certPass = "<your_password>"

    # re-sign the application manifest; should be <application>*.dll.manifest
    $manifestFile = ls | where Name -like "*.dll.manifest" | %{ return $_.Name }
    mage -Update $manifestFile -CertFile $certFile -Password $certPass

    # re-sign the deployment manifest; *.vsto
    $vstoFile = ls | where Name -like "*.vsto" | %{ return $_.FullName }
    #mage -Update $vstoFile -AppManifest $manifestFile -CertFile $certFile -Password $certPass

    $otherVstoFile = ls "..\..\" | where Name -like "*.vsto" | %{ return $_.FullName }
    mage -Update $otherVstoFile -AppManifest $manifestFile -CertFile $certFile -Password $certPass
    Copy-Item $otherVstoFile $vstoFile

    # put .deploy back
    $withDeploy | %{ Rename-Item -Path $_.FullName.Replace(".deploy", "") -NewName $_.FullName }
}