How do I find the fully qualified name of an assembly?

C#DeploymentAssembliesStrongname

C# Problem Overview


How do I find out the fully qualified name of my assembly such as:

MyNamespace.MyAssembly, version=1.0.3300.0, 
Culture=neutral, PublicKeyToken=b77a5c561934e089

I've managed to get my PublicKeyToken using the sn.exe in the SDK, but I'ld like to easily get the full qualified name.

C# Solutions


Solution 1 - C#

This is a shameless copy-paste from I Note It Down and is a simple way to get the FQN for the project output:

Open Visual Studio
Go to Tools –> External Tools –> Add
    Title: Get Qualified Assembly Name
    Command: Powershell.exe
    Arguments: -command "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName"
    Check "Use Output Window".

The new tool appears under Tools –> Get Qualified Assembly Name. When the menu item is selected, the assembly name is given in the output window.

Solution 2 - C#

If you can load the assembly into a .NET application, you can do:

typeof(SomeTypeInTheAssembly).Assembly.FullName

If you cannot then you can use ildasm.exe and it will be in there somewhere:

ildasm.exe MyAssembly.dll /text

Solution 3 - C#

Late to the party, but googled some more about this issue and found this page:

He describes a powershell function that can do this. So. I've never ever used powershell before, but I thought I'd give it a try:

C:\> cd PATH_TO_ASSEMBLY   
C:\PATH_TO_ASSEMBLY>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\PATH_TO_ASSEMBLY> [System.Reflection.AssemblyName]::GetAssemblyName('System.Data.SQLite.dll').FullName
System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
PS C:\PATH_TO_ASSEMBLY>

This does the trick mentioned in other answers by using code, except you don't have to create a project to do this - just type away at the prompt ;)

Solution 4 - C#

Use Assembly.GetExecutingAssembly() to get the current assembly, use Assembly.GetEntryAssembly() to get the assembly that started it all, or use Assembly.GetCallingAssembly() to get the assembly of the code that called your function (one up in the stack).

Once you have the right assembly, use the FullName property, as indicated in other answers.

Solution 5 - C#

Also if you're looking for the Fully Qualified Name for an assembly already in the GAC you can launch a Visual Studio Command Prompt (easiest way to set the correct paths) and use gacutil /l to list all assemblies with their respective FQNs. Use gacutil /l <yourassemblyname> to filter the list to more easily find what you're looking for.

Solution 6 - C#

You can also use open source ILSpy, after you load your assembly it's full name will be diplayed in comments at the top of code window

Solution 7 - C#

If you load the assembly (DLL, EXE, etc.) in Reflector it will tell you the full strong name at the bottom.

Solution 8 - C#

JetBrains dotPeek or Telerik JustDecompile are quite good. Just open the DLL and you have the name right away.

Solution 9 - C#

Couple ways.

In code:

Assembly.FullName e.g.

typeof(Thingy).Assembly.FullName

or, if its an installed assembly, from the GAC using the steps in this post on msdn.

Solution 10 - C#

Being old-school and liking cmd better than powershell, I wrote myself this batch script to do it:

@REM fqn.bat <dll_path>
powershell -command "([system.reflection.assembly]::loadfile('%~f1')).FullName"

The %~f1 expands the first parameter to be an absolute path, so running:

fqn mydll.dll 

Will print the fully-qualified name you want.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIan GView Question on Stackoverflow
Solution 1 - C#David ClarkeView Answer on Stackoverflow
Solution 2 - C#HallgrimView Answer on Stackoverflow
Solution 3 - C#Daren ThomasView Answer on Stackoverflow
Solution 4 - C#Dave Van den EyndeView Answer on Stackoverflow
Solution 5 - C#Per NoaltView Answer on Stackoverflow
Solution 6 - C#csharpfolkView Answer on Stackoverflow
Solution 7 - C#Richard SlaterView Answer on Stackoverflow
Solution 8 - C#uli78View Answer on Stackoverflow
Solution 9 - C#joshua.ewerView Answer on Stackoverflow
Solution 10 - C#Scott StaffordView Answer on Stackoverflow