AssemblyName.ToString Method

Returns the full name of the assembly, also known as the display name.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public override string ToString ()
public String ToString ()
public override function ToString () : String
Not applicable.

Return Value

A String that is the full name of the assembly, or the class name if the full name of the assembly cannot be determined.

See the description of AssemblyName for the format of the returned string.

The following example gets an AssemblyName object for a hypothetical MyAssembly.exe assembly, and then uses the ToString method to retrieve the full assembly name, or display name.

using System;
using System.Reflection;

public class AssemblyName_GetAssemblyName
   public static void Main()
      // Replace the string "MyAssembly.exe" with the name of an assembly,
      // including a path if necessary. If you do not have another assembly
      // to use, you can use whatever name you give to this assembly.
      AssemblyName myAssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe");
      Console.WriteLine("\nDisplaying assembly information:\n");

import System.*;
import System.Reflection.*;
import System.Text.RegularExpressions.*;

public class AssemblyNameGetAssemblyName
    public static void main(String[] args)
        // Get the type of 'System.Object'.
        Type myType = Object.class.ToType();

        // Get the path of 'System.dll'.
        String system = Regex.Replace(myType.get_Assembly().get_CodeBase(), 
            "mscorlib.dll", "System.dll");
        system = Regex.Replace(system, "file:///", "");

        // Get the assembly information and display to the console.
        AssemblyName myAssemblyName = AssemblyName.GetAssemblyName(system);
        Console.WriteLine("\nDisplaying the assembly information of "
            + "'System.dll'\n");
    } //main
} //AssemblyNameGetAssemblyName

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions