visual-studio 使用强名称工具在 .NET 中创建强名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2083950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:25:19  来源:igfitidea点击:

Creating strong names in .NET using Strong Name Tool

.netvisual-studiostrongname

提问by Kumar

After getting the instruction from google, I've tried to create StrongNameFile with the following command:

从谷歌得到指令后,我尝试使用以下命令创建 StrongNameFile:

C:\Program Files\Microsoft Visual Studio 9.0\VC\sn -k StrongNameFile.snk

When I ran the command, I got an error message:

当我运行命令时,我收到一条错误消息:

'sn' is not recognized as an internal or external command, operable program or batch file.

I tried it in the following way:

我通过以下方式尝试过:

C:\Program Files\Microsoft Visual Studio 9.0\SDK\v3.5\Bin>sn -k StrongNameFile.snk

But got the same error. Please somebody help me to solve this problem.

但得到了同样的错误。请有人帮我解决这个问题。

回答by itowlson

Open a Visual Studio Command Prompt instead of a normal command prompt. (Start > Microsoft Visual Studio 2008 > Visual Studio Tools > Visual Studio Command Prompt.) This will set up your PATH to include the .NET Framework SDK directories, which include sn.exe.

打开 Visual Studio 命令提示符而不是普通命令提示符。(开始 > Microsoft Visual Studio 2008 > Visual Studio 工具 > Visual Studio 命令提示符。)这将设置您的 PATH 以包含 .NET Framework SDK 目录,其中包括sn.exe.

If you need to set up the path manually for your own scripts or command prompts, the path you need is:

如果您需要为自己的脚本或命令提示符手动设置路径,您需要的路径是:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

(Exact version number may vary.)

(确切的版本号可能会有所不同。)

回答by CSharper

You're probably using a DOS command prompt. You actually want a Visual Studio Command Prompt when executing sn.

您可能正在使用 DOS 命令提示符。在执行 sn 时,您实际上需要 Visual Studio 命令提示符。

回答by cori

Use the Visual Studio 2008 Command Prompt shortcut in your Start menu:

使用“开始”菜单中的 Visual Studio 2008 命令提示符快捷方式:

All Programs | Microsoft Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt.

所有程序 | 微软 Visual Studio 2008 | Visual Studio 工具 | Visual Studio 2008 命令提示符。

In that, use command "sn".

在那,使用命令“sn”。

That shortcut sets up the path environment vars you need.

该快捷方式设置了您需要的路径环境变量。

回答by bsneeze

As an alternative to all the other answers here, you could have searched your hard disk for sn.exe...

作为此处所有其他答案的替代方案,您可以在硬盘上搜索 sn.exe ...

回答by Lakshmi Swapna

this works in below steps: If you have Visual Studio 2012/2013, open the command prompt of visual studio then browse to the path C:\Program Files (x86)\Microsoft Visual Studio 12.0\SDK\v3.5\Bin> then run below commands Create the key file by running this command: sn -k c:\pairkey.snk Extract the public key to file: sn -p c:\pairkey.snk c:\pubkey Extract public key and public key token from file: sn -tp c:\pubkey

这适用于以下步骤:如果您有 Visual Studio 2012/2013,请打开 Visual Studio 的命令提示符,然后浏览到路径 C:\Program Files (x86)\Microsoft Visual Studio 12.0\SDK\v3.5\Bin> 然后运行以下命令 通过运行以下命令创建密钥文件: sn -kc:\pairkey.snk 将公钥提取到文件:sn -pc:\pairkey.snk c:\pubkey 从文件中提取公钥和公钥令牌:sn -tp c:\公钥