Name Property

AssemblyName.Name Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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)

public string Name { get; set; }

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. When the assembly is created, the Name property is used to set the simple name of the dynamic assembly.

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

public class Example
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
      // Create a dynamic assembly with name 'MyAssembly' and build version ''.
      AssemblyName myAssemblyName = new AssemblyName();
      myAssemblyName.Name = "MyAssembly";
      myAssemblyName.Version = new Version("");

      // Get the assembly builder from the application domain associated with the current thread.
      AssemblyBuilder myAssemblyBuilder = 

      // Create a dynamic module in the assembly.
      ModuleBuilder myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("MyModule");
      // Create a type in the module.
      TypeBuilder myTypeBuilder = myModuleBuilder.DefineType("MyType", 
      // Create a method called 'MyMethod'.
      MethodBuilder myMethodBuilder = myTypeBuilder.DefineMethod("MyMethod", 
         MethodAttributes.Public | MethodAttributes.HideBySig |
         MethodAttributes.Static, typeof(string), null);
      // Get the Intermediate Language generator for the method.
      ILGenerator myILGenerator = myMethodBuilder.GetILGenerator();
      // Load a string.
      myILGenerator.Emit(OpCodes.Ldstr, "Hello World!");
      // Return the string.

      // End the creation of the type.
      Type t = myTypeBuilder.CreateType();

      // Call the static method.
      object result = t.InvokeMember("MyMethod", 
         BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, 
         Type.DefaultBinder, null, null);
      outputBlock.Text += String.Format("MyMethod() returned '{0}'.\n", result);

      // Create an instance of the class.
      object obj = Activator.CreateInstance(t);

/* This example produces the following output:

MyMethod() returned 'Hello World!'.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2016 Microsoft