打开命令提示符并根据您的 Visual Studio 版本和操作系统架构键入以下行之一:
32 位 Windows 上的 VS 2008:
"%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -T <assemblyname>
64 位 Windows 上的 VS 2008:
"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -T <assemblyname>
32 位 Windows 上的 VS 2010:
"%ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe" -T <assemblyname>
64 位 Windows 上的 VS 2010:
"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe" -T <assemblyname>
32 位 Windows 上的 VS 2012:
"%ProgramFiles%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe" -T <assemblyname>
64 位 Windows 上的 VS 2012:
"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe" -T <assemblyname>
64 位 Windows 上的 VS 2015:
"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe" -T <assemblyname>
请注意,对于 VS2012+ 版本,sn.exe 应用程序不再位于 bin 中,而是位于子文件夹中。另外,请注意,对于 64 位,您需要指定 (x86) 文件夹。
如果您更喜欢使用 Visual Studio 命令提示符,只需键入:
sn -T <assembly>
其中<assemblyname> 是您感兴趣的程序集的完整文件路径,如果有空格,则用引号括起来。
您可以在 VS 中将其添加为外部工具,如下所示:
http://blogs.msdn.com/b/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx