Getting the PublicKeyToken of .Net assemblies

前端 未结 13 1089
忘掉有多难
忘掉有多难 2020-11-30 16:57

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

The simplest way I can think of would be a simple right-click, get public key, but this functio

13条回答
  •  粉色の甜心
    2020-11-30 17:50

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

    VS 2008 on 32bit Windows :

    "%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -T 
    

    VS 2008 on 64bit Windows :

    "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -T 
    

    VS 2010 on 32bit Windows :

    "%ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe" -T 
    

    VS 2010 on 64bit Windows :

    "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\bin\sn.exe" -T 
    

    VS 2012 on 32bit Windows :

    "%ProgramFiles%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe" -T 
    

    VS 2012 on 64bit Windows :

    "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe" -T 
    

    VS 2015 on 64bit Windows :

    "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe" -T 
    

    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.

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

    sn -T  
    

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

    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

提交回复
热议问题