获取 .Net 程序集的 PublicKeyToken [英] Getting the PublicKeyToken of .Net assemblies

查看:42
本文介绍了获取 .Net 程序集的 PublicKeyToken的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查找程序集的公钥令牌的最简单方法是什么?

What is the simplest way to find the Public-Key-Token of an assembly?

我能想到的最简单的方法是简单的右键单击,获取公钥,但是没有这个功能,也许有一个 Visual Studio 扩展?

The simplest way I can think of would be a simple right-click, get public key, but this functionality isn't there, maybe there is a Visual Studio Extension for that?

我使用的是 Visual Studio 2010(如果有可用的扩展).

I'm using Visual Studio 2010, if an extension is available.

推荐答案

打开命令提示符并根据您的 Visual Studio 版本和操作系统架构键入以下行之一:

Open a command prompt and type one of the following lines according to your Visual Studio version and Operating System Architecture :

32 位 Windows 上的 VS 2008:

"%ProgramFiles%Microsoft SDKsWindowsv6.0Ainsn.exe" -T <assemblyname>

VS 2008 在 64 位 Windows 上:

"%ProgramFiles(x86)%Microsoft SDKsWindowsv6.0Ainsn.exe" -T <assemblyname>

VS 2010 在 32 位 Windows 上:

"%ProgramFiles%Microsoft SDKsWindowsv7.0Ainsn.exe" -T <assemblyname>

VS 2010 在 64 位 Windows 上:

"%ProgramFiles(x86)%Microsoft SDKsWindowsv7.0Ainsn.exe" -T <assemblyname>

VS 2012 在 32 位 Windows 上:

"%ProgramFiles%Microsoft SDKsWindowsv8.0AinNETFX 4.0 Toolssn.exe" -T <assemblyname>

VS 2012 在 64 位 Windows 上:

"%ProgramFiles(x86)%Microsoft SDKsWindowsv8.0AinNETFX 4.0 Toolssn.exe" -T <assemblyname>

VS 2015 在 64 位 Windows 上:

"%ProgramFiles(x86)%Microsoft SDKsWindowsv10.0AinNETFX 4.6.1 Toolssn.exe" -T <assemblyname>

请注意,对于 VS2012+ 版本,sn.exe 应用程序不再位于 bin 中,而是位于子文件夹中.另外,请注意,对于 64 位,您需要指定 (x86) 文件夹.

Note that for the versions VS2012+, sn.exe application isn't anymore in bin but in a sub-folder. Also, note that for 64bit you need to specify (x86) folder.

如果您更喜欢使用 Visual Studio 命令提示符,只需键入:

If you prefer to use Visual Studio command prompt, just type :

sn -T <assembly> 

其中 是您感兴趣的程序集的完整文件路径,如果有空格,则用引号括起来.

where <assemblyname> is a full file path to the assembly you're interested in, surrounded by quotes if it has spaces.

您可以将其添加为 VS 中的外部工具,如下所示:
http://blogs.msdn.com/b/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx

You can add this as an external tool in VS, as shown here:
http://blogs.msdn.com/b/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx

这篇关于获取 .Net 程序集的 PublicKeyToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆