AssemblyName.Name Property

Gets or sets the simple name of the assembly. This is usually, but not necessarily, the file name of the manifest file of the assembly, minus its extension.

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

'Declaration
Public Property Name As String

Property Value

Type: System.String
The simple name of the assembly.

The manifest file is the file that contains the assembly manifest.

For example, the simple name of a single-file assembly named "MyAssembly.dll" is "MyAssembly".

The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the Name property is used to set the simple name of the dynamic assembly.

Imports System
Imports System.Reflection
Imports System.Threading
Imports System.Reflection.Emit
Imports Microsoft.VisualBasic

Public Class AssemblyName_Constructor

   Public Shared Sub MakeAssembly(myAssemblyName As AssemblyName, fileName As String)
      ' Get the assembly builder from the application domain associated with the current thread. 
      Dim myAssemblyBuilder As AssemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.RunAndSave)
      ' Create a dynamic module in the assembly. 
      Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.DefineDynamicModule("MyModule", fileName)
      ' Create a type in the module. 
      Dim myTypeBuilder As TypeBuilder = myModuleBuilder.DefineType("MyType")
      ' Create a method called 'Main'. 
      Dim myMethodBuilder As MethodBuilder = myTypeBuilder.DefineMethod("Main", MethodAttributes.Public Or MethodAttributes.HideBySig Or MethodAttributes.Static, GetType(object), Nothing)
      Dim myILGenerator As ILGenerator = myMethodBuilder.GetILGenerator()
      ' Use the utility method to generate the IL instructions that print a string to the console.
      myILGenerator.EmitWriteLine("Hello World!")
      ' Generate the 'ret' IL instruction.
      myILGenerator.Emit(OpCodes.Ret)
      ' End the creation of the type.
      myTypeBuilder.CreateType()
      ' Set the method with name 'Main' as the entry point in the assembly.
      myAssemblyBuilder.SetEntryPoint(myMethodBuilder)
      myAssemblyBuilder.Save(fileName)
   End Sub 'MakeAssembly


   Public Shared Sub Main()


      ' Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'. 
      Dim myAssemblyName As New AssemblyName()
      myAssemblyName.Name = "MyAssembly"
      myAssemblyName.Version = New Version("1.0.0.2001")
      MakeAssembly(myAssemblyName, "MyAssembly.exe")

      ' Get all the assemblies currently loaded in the application domain. 
      Dim myAssemblies As [Assembly]() = Thread.GetDomain().GetAssemblies()

      ' Get the dynamic assembly named 'MyAssembly'.  
      Dim myAssembly As [Assembly] = Nothing 
      Dim i As Integer 
      For i = 0 To myAssemblies.Length - 1
         If [String].Compare(myAssemblies(i).GetName().Name, "MyAssembly") = 0 Then
            myAssembly = myAssemblies(i)
         End If 
      Next i
      If Not (myAssembly Is Nothing) Then
         Console.WriteLine(ControlChars.Cr + "Displaying the assembly name" + ControlChars.Cr)
         Console.WriteLine(myAssembly)
      End If 
   End Sub 'Main 
End Class 'AssemblyName_Constructor 

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft