How do I find the PublicKeyToken for a particular dll?

后端 未结 10 603
后悔当初
后悔当初 2020-12-04 06:10

I need to recreate a provider in my web.config file that looks something like this:


  

        
相关标签:
10条回答
  • 2020-12-04 06:38

    Just adding more info, I wasn't able to find sn.exe utility in the mentioned locations, in my case it was in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin

    0 讨论(0)
  • 2020-12-04 06:40

    Assembly.LoadFile(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\system.data.dll").FullName

    Will result in

    System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    0 讨论(0)
  • 2020-12-04 06:45

    Answer is very simple use the .NET Framework tools sn.exe. So open the Visual Studio 2008 Command Prompt and then point to the dll’s folder you want to get the public key,

    Use the following command,

    sn –T myDLL.dll

    This will give you the public key token. Remember one thing this only works if the assembly has to be strongly signed.

    Example

    C:\WINNT\Microsoft.NET\Framework\v3.5>sn -T EdmGen.exe
    
    Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.21022.8
    Copyright (c) Microsoft Corporation.  All rights reserved.
    
    Public key token is b77a5c561934e089
    0 讨论(0)
  • 2020-12-04 06:48

    I use Windows Explorer, navigate to C:\Windows\assembly , find the one I need. From the Properties you can copy the PublicKeyToken.

    This doesn't rely on Visual Studio or any other utilities being installed.

    0 讨论(0)
提交回复
热议问题