The reason I want to sign the dll is because I want to add it to the Global Assembly Cache. The assembly is a css parsing engine written in Java and ported to J#. I use VS2008 so I can't make J# projects. It doesn't have a strong name key assigned to it and I have no idea how to do it now that it's built.
我想签署DLL的原因是因为我想将它添加到全局程序集缓存中。该程序集是一个用Java编写并移植到J#的css解析引擎。我使用VS2008所以我不能制作J#项目。它没有分配一个强大的名称密钥,我不知道如何建立它现在。
Anyone have any ideas?
有人有主意吗?
5 个解决方案
#1
41
After a little searching, I found this post that explains one way of doing it.
经过一番搜索,我发现这篇文章解释了一种方法。
Exerpt:
Exerpt:
From a VS.NET command prompt, enter the following:
在VS.NET命令提示符下,输入以下内容:
- Generate a KeyFile: sn -k keyPair.snk
- 生成KeyFile:sn -k keyPair.snk
- Obtain the MSIL for the provided assembly: ildasm providedAssembly.dll /out:providedAssembly.il
- 获取提供的程序集的MSIL:ildasm providedAssembly.dll /out:providedAssembly.il
- Rename/move the original assembly: ren providedAssembly.dll providedAssembly.dll.orig
- 重命名/移动原始程序集:ren provideAssembly.dll提供了assembly.dll.orig
- Create a new assembly from the MSIL output and your assembly KeyFile: ilasm providedAssembly.il /dll /key= keyPair.snk
- 从MSIL输出和程序集KeyFile创建一个新程序集:ilasm providedAssembly.il / dll / key = keyPair.snk
#2
18
Step 1: Dis-assemble the assembly
第1步:拆卸组件
ildasm myTest.dll /out:myTest.il
Step 2: Re-Assemble using your strong-name key
第2步:使用强名称密钥重新汇编
ilasm myTest.il /res:myTest.res /dll /key:myTest.snk /out:myTestSN.dll
For verification you can use following command:
要进行验证,您可以使用以下命令:
sn -vf myTestSN.dll
Hope this helps!
希望这可以帮助!
#3
3
This link also shows how to do it, including when one of the 3rd party assemblies you're signing has a reference to another unsigned assembly that you're signing:
此链接还显示了如何执行此操作,包括当您签名的第三方程序集之一引用了您要签名的另一个未签名程序集时:
http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing
http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing
Edit: sorry, link is busted.
编辑:抱歉,链接已被破坏。
#4
1
The Strong Name tool can re-sign an existing assembly, using the -R option. However, from what I understand, the assembly has to be previously signed or delay-signed... not sure you can use it with an unsigned assembly, but you can give it a try
强名称工具可以使用-R选项重新签名现有程序集。但是,根据我的理解,程序集必须先签名或延迟签名...不确定是否可以将它与未签名的程序集一起使用,但是你可以尝试一下
#5
0
Thx especially PJ8 for posting an answer 8 years ago that still saved me today. "My" assembly needed to go in the GAC but was dependent on SQLite-pcl-net which as of version 1.3.1 is not strong-named although it is now dependent on the strong-named SQLitePCLRaw.bundle_green. So I had to sign SQLite-pcl-net in order to sign my own assembly in other words. I ended up with a cradle-to-grave .bat file consolidated from info in this post and a few other places I traveled today. The "pros" are 1. that this .bat runs in the location of the assembly that you want to sign 2. shows at least a hint as to where the three tools might be located on a dev machine. 3. shows all the steps in order. The "con" of course is that your mileage may vary as to where ildasm, ilasm and sn are actually located on your particular PC. Anyway cheers.
特别是PJ8在8年前发布了答案,今天仍然救了我。 “我的”程序集需要进入GAC,但依赖于SQLite-pcl-net,虽然它现在依赖于强名称的SQLitePCLRaw.bundle_green,但它在版本1.3.1中并没有强名称。所以我不得不签署SQLite-pcl-net,换句话说就是签署我自己的程序集。我最后得到了一篇从这篇文章中的信息中巩固的从摇篮到坟墓的.bat文件以及我今天旅行过的其他几个地方。 “pros”是1.这个.bat在要签名的程序集的位置运行2.至少显示三个工具在dev机器上的位置的提示。 3.按顺序显示所有步骤。 “con”当然是你的里程可能会有所不同,ildasm,ilasm和sn实际上位于你的特定PC上。无论如何欢呼。
REM Create a new, random key pair
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -k SQLite-net.snk
REM Store the key in the container MySQLiteKeys in the strong name Cryptographic Services Provider (CSP).
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -i SQLite-net.snk MySQLiteKeys
REM Disassemble to Intermediate Language
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\ildasm" SQLite-net.dll /out:SQLite-net.il
REM Rename original file
ren SQLite-net.dll SQLite-net.dll.orig
REM Reassemble to a strong-named version
"c:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm" SQLite-net.il /dll /key=SQLite-net.snk /out:SQLite-net.dll
REM Verify the assembly
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -v SQLite-net.dll
REM Deletes MySQLiteKeys from the default CSP
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -d MySQLiteKeys
REM View results
pause
#1
41
After a little searching, I found this post that explains one way of doing it.
经过一番搜索,我发现这篇文章解释了一种方法。
Exerpt:
Exerpt:
From a VS.NET command prompt, enter the following:
在VS.NET命令提示符下,输入以下内容:
- Generate a KeyFile: sn -k keyPair.snk
- 生成KeyFile:sn -k keyPair.snk
- Obtain the MSIL for the provided assembly: ildasm providedAssembly.dll /out:providedAssembly.il
- 获取提供的程序集的MSIL:ildasm providedAssembly.dll /out:providedAssembly.il
- Rename/move the original assembly: ren providedAssembly.dll providedAssembly.dll.orig
- 重命名/移动原始程序集:ren provideAssembly.dll提供了assembly.dll.orig
- Create a new assembly from the MSIL output and your assembly KeyFile: ilasm providedAssembly.il /dll /key= keyPair.snk
- 从MSIL输出和程序集KeyFile创建一个新程序集:ilasm providedAssembly.il / dll / key = keyPair.snk
#2
18
Step 1: Dis-assemble the assembly
第1步:拆卸组件
ildasm myTest.dll /out:myTest.il
Step 2: Re-Assemble using your strong-name key
第2步:使用强名称密钥重新汇编
ilasm myTest.il /res:myTest.res /dll /key:myTest.snk /out:myTestSN.dll
For verification you can use following command:
要进行验证,您可以使用以下命令:
sn -vf myTestSN.dll
Hope this helps!
希望这可以帮助!
#3
3
This link also shows how to do it, including when one of the 3rd party assemblies you're signing has a reference to another unsigned assembly that you're signing:
此链接还显示了如何执行此操作,包括当您签名的第三方程序集之一引用了您要签名的另一个未签名程序集时:
http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing
http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing
Edit: sorry, link is busted.
编辑:抱歉,链接已被破坏。
#4
1
The Strong Name tool can re-sign an existing assembly, using the -R option. However, from what I understand, the assembly has to be previously signed or delay-signed... not sure you can use it with an unsigned assembly, but you can give it a try
强名称工具可以使用-R选项重新签名现有程序集。但是,根据我的理解,程序集必须先签名或延迟签名...不确定是否可以将它与未签名的程序集一起使用,但是你可以尝试一下
#5
0
Thx especially PJ8 for posting an answer 8 years ago that still saved me today. "My" assembly needed to go in the GAC but was dependent on SQLite-pcl-net which as of version 1.3.1 is not strong-named although it is now dependent on the strong-named SQLitePCLRaw.bundle_green. So I had to sign SQLite-pcl-net in order to sign my own assembly in other words. I ended up with a cradle-to-grave .bat file consolidated from info in this post and a few other places I traveled today. The "pros" are 1. that this .bat runs in the location of the assembly that you want to sign 2. shows at least a hint as to where the three tools might be located on a dev machine. 3. shows all the steps in order. The "con" of course is that your mileage may vary as to where ildasm, ilasm and sn are actually located on your particular PC. Anyway cheers.
特别是PJ8在8年前发布了答案,今天仍然救了我。 “我的”程序集需要进入GAC,但依赖于SQLite-pcl-net,虽然它现在依赖于强名称的SQLitePCLRaw.bundle_green,但它在版本1.3.1中并没有强名称。所以我不得不签署SQLite-pcl-net,换句话说就是签署我自己的程序集。我最后得到了一篇从这篇文章中的信息中巩固的从摇篮到坟墓的.bat文件以及我今天旅行过的其他几个地方。 “pros”是1.这个.bat在要签名的程序集的位置运行2.至少显示三个工具在dev机器上的位置的提示。 3.按顺序显示所有步骤。 “con”当然是你的里程可能会有所不同,ildasm,ilasm和sn实际上位于你的特定PC上。无论如何欢呼。
REM Create a new, random key pair
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -k SQLite-net.snk
REM Store the key in the container MySQLiteKeys in the strong name Cryptographic Services Provider (CSP).
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -i SQLite-net.snk MySQLiteKeys
REM Disassemble to Intermediate Language
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\ildasm" SQLite-net.dll /out:SQLite-net.il
REM Rename original file
ren SQLite-net.dll SQLite-net.dll.orig
REM Reassemble to a strong-named version
"c:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm" SQLite-net.il /dll /key=SQLite-net.snk /out:SQLite-net.dll
REM Verify the assembly
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -v SQLite-net.dll
REM Deletes MySQLiteKeys from the default CSP
"c:\program files (x86)\microsoft sdks\windows\v8.1a\bin\NETFX 4.5.1 Tools\sn" -d MySQLiteKeys
REM View results
pause