Suppose I want to display the full name of an assembly, given only a path to the assembly file.
I know I could write a command line program or powershell script easily enough, but does the runtime include a command that I could use? (I've seen gacutil do it for assemblies that are in the gac, but about assemblies that are not registered?)
I think you're looking for System.Reflection.AssemblyName.GetAssemblyName:
AssemblyName name = AssemblyName.GetAssemblyName(@"C:\path\assembly.dll");
Console.WriteLine(name.FullName);
Unlike the solution using Assembly.Load, this will not load the assembly into your AppDomain. This will allow you to get the AssemblyName for an assembly without having to resolve any references that assembly has, and without executing any code (e.g. module static constructors) in the assembly. It will even let you get the AssemblyName of an assembly that targets a version of the .NET Framework that differs from the version on which your application is running.
The main problematic part of a full-name is usually the public key token. You can obtain it by entering this into the Visual Studio Command Prompt Window:
sn -T path\to\your.dll
Personally, I find it easier just to load the dll into reflector, though. That shows the full name in the bottom panel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With