Sign a .NET Assembly with a Strong Name Without Recompiling
来源:互联网 发布:linux查网关 编辑:程序博客网 时间:2024/05/22 16:44
Signing a .NET assembly with a strong name is easy in Visual Studio. However, what if this is a 3rd party assembly and you don't have the source?
For me, I have an application that has a requirement that all assemblies are signed with a strong name. One of the assemblies I am using isRestSharp. I like to contribute to RestSharp and I didn't want to modify the project file to sign the assembly as I didn't want that to go back to the repository when I had some changes to contribute.
Not a problem. What I have is a batch file that disassembles the DLL to IL and then reassembles the IL back into a DLL and includes my key file. This way I get to keep the original DLL for projects that I don't need the assembly to have a strong name and a separate one that is signed with the strong name for the projects where I need that.
Here's what I did:
Now, whenever I do a new release build, I just run the batch file and I have a signed copy to use, and I did it without changing the project file to do it.
For me, I have an application that has a requirement that all assemblies are signed with a strong name. One of the assemblies I am using isRestSharp. I like to contribute to RestSharp and I didn't want to modify the project file to sign the assembly as I didn't want that to go back to the repository when I had some changes to contribute.
Not a problem. What I have is a batch file that disassembles the DLL to IL and then reassembles the IL back into a DLL and includes my key file. This way I get to keep the original DLL for projects that I don't need the assembly to have a strong name and a separate one that is signed with the strong name for the projects where I need that.
Here's what I did:
- In the Release build folder I created the following:
- The key file (create using sn.exe -k MyPublicPrivateKeyFile.snk)
- A subfolder to contain the signed assembly, mine is named "Signed"
- A batch file (see below)
- Create a batch file in the Release folder named "SignAssembly.bat" with the following contents:
del .\Signed\RestSharp.* /F"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\ildasm.exe" .\RestSharp.dll /out:.\Signed\RestSharp.il"C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe" .\Signed\RestSharp.il /dll /key=.\RestSharp.snk /output=.\Signed\RestSharp.dllpauseThe first line deletes any previously signed assembly. Second line uses ILDASM to disassemble the DLL to IL in the "Signed" folder as RestSharp.il. The third line reassembles the IL into an assembly using ILASM and tells it to use the IL file and the key file. That's it.
Now, whenever I do a new release build, I just run the batch file and I have a signed copy to use, and I did it without changing the project file to do it.
- Sign a .NET Assembly with a Strong Name Without Recompiling
- Sign Assembly with strong name
- Giving a .NET Assembly a Strong Name
- How to sign C++/CLI assemblies with a strong name?
- HOW TO: Create an Assembly with a Strong Name
- 关于解决 C# CSC: Assembly generation failed -- Referenced assembly ... does not have a strong name
- 关于.net assembly的strong name问题
- How to sign a .Sis file with Self-Sign Certificate
- 英语笔记:写作:Nothing succeeds without a strong will
- strong name in .NET
- A Sample .NET DeProtector - whole assembly protection
- Build and Deploy a .NET COM Assembly
- Implementing a Recursive Procedure with IA32 and Y86 Assembly Code
- RMAN-06217: not connected to auxiliary database with a net service name
- DLL Hell & .Net Strong Name
- .NET Assembly - Strong Names and Signing
- a strong community culture
- 如何创建强命名程序集(Strong Name Assembly
- php snoopy 试用心得
- linux 60 个常用命令
- java 加解密
- <context-param>与<init-param>的区别与作用
- request 获取 参数 url
- Sign a .NET Assembly with a Strong Name Without Recompiling
- 第八周任务2
- js 获取客户端ip的方法
- Create PowerPoint slides from Silverlight by taking snaps of pages
- 超简洁的js 日期选择控件
- 如何让IE6/IE7/IE8支持HTML5标签
- jsTree刷新
- proxool连接池连接sql server2005数据库的问题
- Struts2 通配符映射(wildcard mappings) 多个请求一个action处理