I need to recreate a provider in my web.config file that looks something like this:
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.
As @CRice said you can use the below method to get a list of dependent assembly with publicKeyToken
public static int DependencyInfo(string args)
{
Console.WriteLine(Assembly.LoadFile(args).FullName);
Console.WriteLine(Assembly.LoadFile(args).GetCustomAttributes(typeof(System.Runtime.Versioning.TargetFrameworkAttribute), false).SingleOrDefault());
try {
var assemblies = Assembly.LoadFile(args).GetReferencedAssemblies();
if (assemblies.GetLength(0) > 0)
{
foreach (var assembly in assemblies)
{
Console.WriteLine(" - " + assembly.FullName + ", ProcessorArchitecture=" + assembly.ProcessorArchitecture);
}
return 0;
}
}
catch(Exception e) {
Console.WriteLine("An exception occurred: {0}", e.Message);
return 1;
}
finally{}
return 1;
}
i generally use it as a LinqPad script you can call it as
DependencyInfo("@c:\MyAssembly.dll");
from the code
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.
Using sn.exe utility:
sn -T YourAssembly.dll
or loading the assembly in Reflector.
If you have the DLL added to your project, you can open the csproj file and see the Reference tag.
Example:
<Reference Include="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
Using PowerShell, you can execute this statement:
([system.reflection.assembly]::loadfile("c:\MyDLL.dll")).FullName
The output will provide the Version, Culture and PublicKeyToken as shown below:
MyDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a