How can I retrieve an assembly's qualified type name?


Question

How can I generate a assembly qualified type name?

For an example, when configuring a membership provider, I would have to provide a assembly qualified type name for "SqlMembershipProvider" (in this example, i have copied the below configuration from somewhere) in "type" attribute.

How do you generate that assembly qualified type name? Does it have to be typed manually everytime by examining an assembly type?

<membership>
  <providers>
    <clear />
    <add name="AspNetSqlMembershipProvider"
           type="System.Web.Security.SqlMembershipProvider,
           System.Web, Version=2.0.0.0,
           Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
           connectionStringName="LocalSqlServer"/>
  </providers>
</membership>

[UPDATE]: Simpler PowerShell version

PS>([System.String]).AssemblyQualifiedName
System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
1
4
5/23/2017 12:09:02 PM

Accepted Answer

This is a nice handy tool (shell extension with source code) for copying the fully qualified name to clipboard by right clicking on any assembly.

Update: After seeing the comment from dance2die, thought of putting together a sample powershell script to export the type name to a csv file.

> [System.Reflection.Assembly]::LoadWithPartialName("System.Web")

> [System.Web.Security.SqlMembershipProvider] | select {$_.UnderlyingSystemType.AssemblyQualifiedName } | export-csv c:\typenames.csv

Using C#, if you want to generate the assembly qualified type name with all the references set, it is easy to build a test script using reflection..

using System;
using System.Reflection;
........

Type ty = typeof(System.Web.Security.SqlMembershipProvider);
string fullname = ty.AssemblyQualifiedName;
//"System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
8
1/14/2009 5:00:25 PM

The easiest way to find that information is to use Reflector, load the assembly, and copy the Name out of the assembly's manifest. The manifest information will be in the bottom pane of Reflector when your assembly is selected in the window above.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon