在构建后事件之前还是之后,程序集是否使用强名称签名?

编程入门 行业动态 更新时间:2024-10-26 12:30:55
本文介绍了在构建后事件之前还是之后,程序集是否使用强名称签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 editbin 修改程序集的堆栈大小,请参阅 增加主程序的堆栈大小或者为递归代码块创建一个具有更大堆栈大小的新线程?

I'm modifying the stack size of an assembly using editbin, see Increase stack size of main program or create a new thread with larger stack size for recursive code blocks?

现在我问自己:在构建后事件之前还是之后,程序集是否使用强名称签名?因为 editbin 正在构建后事件中更改程序集.

Now I'm asking myself: Is an assembly signed with a strong name before or after the post-build event? Because editbin is changing the assembly in the post-build event.

我的帖子构建事件看起来像这样:

My post build-event looks like that:

"$(DevEnvDir)....VCineditbin.exe" /STACK:16777216 "$(TargetPath)"

我的项目 .csproj 文件包含以下几行:

And my project .csproj file contains the following lines:

<PropertyGroup> <SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>..STRONGNAME.snk</AssemblyOriginatorKeyFile> </PropertyGroup> <PropertyGroup> <PostBuildEvent>"$(DevEnvDir)....VCineditbin.exe" /STACK:16777216 "$(TargetPath)"</PostBuildEvent> </PropertyGroup>

推荐答案

在构建后事件之前使用强名称对程序集进行签名.这意味着 editbin 将更改该程序集并且签名不再有效.

An assembly is signed with a strong name before the post-build event. That means editbin will change that assembly and the signature is not valid anymore.

sn.exe -v assembly.exe 将返回 Failed to verify assembly -- Strong name validation failed ...

获得使用 editbin 修改的有效签名程序集的解决方法是使用 AfterCompile 事件并使用 sn 重新签名程序集.

A workaround to get a valid signed assembly which was modified using editbin is to use the AfterCompile event and to resign the assembly using sn.

项目文件应如下所示:

<Target Name="AfterCompile"> <Exec Command=" &quot;$(DevEnvDir)....VCineditbin.exe&quot; /STACK:16777216 &quot;$(ProjectDir)obj$(ConfigurationName)$(TargetFileName)&quot; echo $(FrameworkSDKDir)binNETFX 4.5.1 Tools &quot;$(FrameworkSDKDir)binNETFX 4.5.1 Toolssn.exe&quot; -Ra &quot;$(ProjectDir)obj$(ConfigurationName)$(TargetFileName)&quot; &quot;$(SolutionDir)STRONGNAME.snk&quot; " /> </Target> <PropertyGroup> <PostBuildEvent>REM "See AfterCompile for stack size and resigning"</PostBuildEvent> </PropertyGroup>

更多推荐

在构建后事件之前还是之后,程序集是否使用强名称签名?

本文发布于:2023-11-03 01:17:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1553892.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   事件   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!