How do I find the PublicKeyToken for a particular dll?
how to change publickeytoken of dll
does not represent a strongly named assembly
sn exe sign
the located assembly's manifest definition does not match the assembly reference
verify strong name signature
failed to convert key to token -- invalid assembly public key.
I need to recreate a provider in my web.config file that looks something like this:
<membership defaultProvider="AspNetSqlMemProvider"> <providers> <clear/> <add connectionStringName="TRAQDBConnectionString" applicationName="TRAQ" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" name="AspNetSqlMemProvider" type="System.Web.Security.SqlMembershipProvider, Version=188.8.131.52, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> </providers> </membership>
However, I get a runtime error saying this assembly cannot be loaded, and I think it is because I have the wrong PublicKeyToken. How do I look up the PublicKeyToken for my assembly?
Alternatively, am I going entirely the wrong way with this?
Using PowerShell, you can execute this statement:
The output will provide the Version, Culture and PublicKeyToken as shown below:
MyDLL, Version=184.108.40.206, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
What is the role of public key token?, is to let you refer to keys without saying the whole key. To determine the DLL information, you need to run your project, since this process will work only in debug mode. You need to put a breakpoint somewhere in your cs page. And when the break hits, you need to go to the immediate window by pressing Alt+Ctrl+I. Now a window will open, there you need to type the following:
Using sn.exe utility:
sn -T YourAssembly.dll
or loading the assembly in Reflector.
How to find out the Public Key Token for an assembly (DLL) file , How do I get PublicKeyToken of assembly in Visual Studio 2017? In response to a question on my article How to install a DLL to the GAC on Windows Server 2012 using only PowerShell (without having to install SDK or Visual Studio) here’s how you can find the PublicKeyToken for a DLL using only PowerShell. ([system.reflection.assembly]::loadfile("c:\temp\MyDLL.dll")).FullName
If you have the DLL added to your project, you can open the csproj file and see the Reference tag.
<Reference Include="System.Web.Mvc, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
How to: Determine the Public Key Token of the Windows Client , Find public key token value of an assembly file. Open Visual Studio Command Prompt (Start > Visual Studio > Visual Studio Tools > Developer Command Prompt) Run the command below. It will display both public key token and public key. Make sure to replace C:\Temp\Oracle. DataAccess. dll with the full path of your DLL Hello, I found the solution for my answer. When you navigate to assembly folder there you will find .dll files just right click in the appropriate .dll file-> properties and there you can find the PublicKeyToken. Thanks – Chandra Shekhar Jun 7 '11 at 11:12
sn -T <assembly> in Visual Studio command line.
If an assembly is installed in the global assembly cache, it's easier to go to
C:\Windows\assembly and find it in the list of GAC assemblies.
On your specific case, you might be mixing type full name with assembly reference, you might want to take a look at MSDN.
How to: Reference a strong-named assembly, To determine the public key token. Locate the sn.exe file. The location will depend on your operating system and the installed Microsoft . NET Framework SDK. At the command prompt, change to the directory that contains the sn.exe utility. Type the following command. Copy. sn.exe -T <assembly> Press Enter and note the 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 functionality isn't there, maybe there is a Visual Studio Extension for that? I'm using Visual Studio 2010, if an extension is available..net visual-studio visual-studio-2010 public-key
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.
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
How to find the Version, Culture and PublicKeyToken of an , NET assembly, either at compile time or runtime. public key and public key token for a specific assembly by using the following Strong Name In this quick post we will consider another scenario – how to get the public key token string value of a strongly named assembly (dll). This is easily accomplished by using the Strong Name Tool as well by simply using the -T switch and specifying the path and name of the dll for which to retrieve the public key token.
How do I find the PublicKeyToken for a particular dll?, Any idea on how to get the version and token details of DLLs already present on the server, without specifying a particular path of DLL?? Like Go to Run : type the path of DLL for which you need public key. You will find 2 files : 1. __AssemblyInfo_.ini 2. DLL file. Open this __AssemblyInfo_.ini file in notepad , here you can see Public Key Token.
Find PublicKeyToken of a DLL, how to get publickeytoken of assembly visual studio 2017 how to change publickeytoken of dll publickeytoken=null does not represent a strongly named When you set the public key by calling the SetPublicKey method, you must also use the SetPublicKeyToken method to provide a public key token. Otherwise, a SecurityException is thrown when the GetPublicKey method is called.
How to Find the Public Key Token for a Strongly-Named Assembly , This article shows how to determine the public key token of a DLL that we that the output given here will be different depending on your DLL. I have found that the easiest way to find the publickeytoken and version information is to look in the c:\windows\assembly which clearly shows all this information. I also think that the Q release downloads should be accompanied by a what to do guide particularly if you are using Telerik with SharePoint.
- Possible duplicate of Getting the PublicKeyToken of .Net assemblies
- Thanks! your method is the only one that worked for me sn -T dllname.dll would only show help text when I ran it
- That's perfect! Avoids installing extra tools.
- great! this works also when there is no PublicKeyToken available (ie. unsigned assemblies)
- In C# Interactive, you can call: Console.WriteLine(System.Reflection.Assembly.LoadFile(@"c:\some.dll").FullName);
- Annoyingly, PowerShell.exe keeps a lock on the dll even after the call completed. I needed to close the PowerShell console before I could build my solution again.
- sn.exe can typically be found at one of the following locations under C:\Program Files (x86)\Microsoft SDKs\Windows: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin, C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64, C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
- Mind it, the key is case-sensitive. -t (lower case) will give the "Failed to convert key to token -- Invalid assembly public key.", which will send you searching in the wrong direction.
- If you have Visual Studio 2013 and you can't find "Developer Command Prompt for VS2013" go have a look here how to fix it: stackoverflow.com/a/22702405/187650
- Note that this tool does not come with Windows.
- If you open up a visual studio command prompt it should be on your path.
- Check this out: stackoverflow.com/questions/3045033/…