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=2.0.0.0, 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?
sn -T <assembly>
in Visual Studio command line. If an assembly is installed in the global assembly cache, it's easier to go toC:\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.
You can also check by following method.
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.
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,
This will give you the public key token. Remember one thing this only works if the assembly has to be strongly signed.
Example
As @CRice said you can use the below method to get a list of dependent assembly with publicKeyToken
i generally use it as a LinqPad script