AssemblyBuilder Třída

Definice

Definuje a představuje dynamické sestavení.

public ref class AssemblyBuilder sealed : System::Reflection::Assembly
public ref class AssemblyBuilder abstract : System::Reflection::Assembly
public ref class AssemblyBuilder sealed : System::Reflection::Assembly, System::Runtime::InteropServices::_AssemblyBuilder
public sealed class AssemblyBuilder : System.Reflection.Assembly
public abstract class AssemblyBuilder : System.Reflection.Assembly
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
public sealed class AssemblyBuilder : System.Reflection.Assembly, System.Runtime.InteropServices._AssemblyBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyBuilder : System.Reflection.Assembly, System.Runtime.InteropServices._AssemblyBuilder
type AssemblyBuilder = class
    inherit Assembly
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
type AssemblyBuilder = class
    inherit Assembly
    interface _AssemblyBuilder
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type AssemblyBuilder = class
    inherit Assembly
    interface _AssemblyBuilder
Public NotInheritable Class AssemblyBuilder
Inherits Assembly
Public MustInherit Class AssemblyBuilder
Inherits Assembly
Public NotInheritable Class AssemblyBuilder
Inherits Assembly
Implements _AssemblyBuilder
Dědičnost
AssemblyBuilder
Atributy
Implementuje

Příklady

Následující příklad kódu ukazuje, jak definovat a používat dynamické sestavení. Ukázkové sestavení obsahuje jeden typ , MyDynamicTypekterý má privátní pole, vlastnost, která získá a nastaví privátní pole, konstruktory, které inicializují privátní pole, a metodu, která vynásobí uživatelem zadané číslo hodnotou privátního pole a vrátí výsledek.

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;

void main()
{
    // This code creates an assembly that contains one type,
    // named "MyDynamicType", that has a private field, a property
    // that gets and sets the private field, constructors that
    // initialize the private field, and a method that multiplies
    // a user-supplied number by the private field value and returns
    // the result. In Visual C++ the type might look like this:
    /*
      public ref class MyDynamicType
      {
      private:
          int m_number;

      public:
          MyDynamicType() : m_number(42) {};
          MyDynamicType(int initNumber) : m_number(initNumber) {};
      
          property int Number
          {
              int get() { return m_number; }
              void set(int value) { m_number = value; }
          }

          int MyMethod(int multiplier)
          {
              return m_number * multiplier;
          }
      };
    */
      
    AssemblyName^ aName = gcnew AssemblyName("DynamicAssemblyExample");
    AssemblyBuilder^ ab = 
        AssemblyBuilder::DefineDynamicAssembly(
            aName, 
            AssemblyBuilderAccess::Run);

    // The module name is usually the same as the assembly name
    ModuleBuilder^ mb = 
        ab->DefineDynamicModule(aName->Name);
      
    TypeBuilder^ tb = mb->DefineType(
        "MyDynamicType", 
         TypeAttributes::Public);

    // Add a private field of type int (Int32).
    FieldBuilder^ fbNumber = tb->DefineField(
        "m_number", 
        int::typeid, 
        FieldAttributes::Private);

    // Define a constructor that takes an integer argument and 
    // stores it in the private field. 
    array<Type^>^ parameterTypes = { int::typeid };
    ConstructorBuilder^ ctor1 = tb->DefineConstructor(
        MethodAttributes::Public, 
        CallingConventions::Standard, 
        parameterTypes);

    ILGenerator^ ctor1IL = ctor1->GetILGenerator();
    // For a constructor, argument zero is a reference to the new
    // instance. Push it on the stack before calling the base
    // class constructor. Specify the default constructor of the 
    // base class (System::Object) by passing an empty array of 
    // types (Type::EmptyTypes) to GetConstructor.
    ctor1IL->Emit(OpCodes::Ldarg_0);
    ctor1IL->Emit(OpCodes::Call, 
        Object::typeid->GetConstructor(Type::EmptyTypes));
    // Push the instance on the stack before pushing the argument
    // that is to be assigned to the private field m_number.
    ctor1IL->Emit(OpCodes::Ldarg_0);
    ctor1IL->Emit(OpCodes::Ldarg_1);
    ctor1IL->Emit(OpCodes::Stfld, fbNumber);
    ctor1IL->Emit(OpCodes::Ret);

    // Define a default constructor that supplies a default value
    // for the private field. For parameter types, pass the empty
    // array of types or pass nullptr.
    ConstructorBuilder^ ctor0 = tb->DefineConstructor(
        MethodAttributes::Public, 
        CallingConventions::Standard, 
        Type::EmptyTypes);

    ILGenerator^ ctor0IL = ctor0->GetILGenerator();
    ctor0IL->Emit(OpCodes::Ldarg_0);
    ctor0IL->Emit(OpCodes::Call, 
        Object::typeid->GetConstructor(Type::EmptyTypes));
    // For a constructor, argument zero is a reference to the new
    // instance. Push it on the stack before pushing the default
    // value on the stack.
    ctor0IL->Emit(OpCodes::Ldarg_0);
    ctor0IL->Emit(OpCodes::Ldc_I4_S, 42);
    ctor0IL->Emit(OpCodes::Stfld, fbNumber);
    ctor0IL->Emit(OpCodes::Ret);

    // Define a property named Number that gets and sets the private 
    // field.
    //
    // The last argument of DefineProperty is nullptr, because the
    // property has no parameters. (If you don't specify nullptr, you must
    // specify an array of Type objects. For a parameterless property,
    // use the built-in array with no elements: Type::EmptyTypes)
    PropertyBuilder^ pbNumber = tb->DefineProperty(
        "Number", 
        PropertyAttributes::HasDefault, 
        int::typeid, 
        nullptr);
      
    // The property "set" and property "get" methods require a special
    // set of attributes.
    MethodAttributes getSetAttr = MethodAttributes::Public | 
        MethodAttributes::SpecialName | MethodAttributes::HideBySig;

    // Define the "get" accessor method for Number. The method returns
    // an integer and has no arguments. (Note that nullptr could be 
    // used instead of Types::EmptyTypes)
    MethodBuilder^ mbNumberGetAccessor = tb->DefineMethod(
        "get_Number", 
        getSetAttr, 
        int::typeid, 
        Type::EmptyTypes);
      
    ILGenerator^ numberGetIL = mbNumberGetAccessor->GetILGenerator();
    // For an instance property, argument zero is the instance. Load the 
    // instance, then load the private field and return, leaving the
    // field value on the stack.
    numberGetIL->Emit(OpCodes::Ldarg_0);
    numberGetIL->Emit(OpCodes::Ldfld, fbNumber);
    numberGetIL->Emit(OpCodes::Ret);
    
    // Define the "set" accessor method for Number, which has no return
    // type and takes one argument of type int (Int32).
    MethodBuilder^ mbNumberSetAccessor = tb->DefineMethod(
        "set_Number", 
        getSetAttr, 
        nullptr, 
        gcnew array<Type^> { int::typeid });
      
    ILGenerator^ numberSetIL = mbNumberSetAccessor->GetILGenerator();
    // Load the instance and then the numeric argument, then store the
    // argument in the field.
    numberSetIL->Emit(OpCodes::Ldarg_0);
    numberSetIL->Emit(OpCodes::Ldarg_1);
    numberSetIL->Emit(OpCodes::Stfld, fbNumber);
    numberSetIL->Emit(OpCodes::Ret);
      
    // Last, map the "get" and "set" accessor methods to the 
    // PropertyBuilder. The property is now complete. 
    pbNumber->SetGetMethod(mbNumberGetAccessor);
    pbNumber->SetSetMethod(mbNumberSetAccessor);

    // Define a method that accepts an integer argument and returns
    // the product of that integer and the private field m_number. This
    // time, the array of parameter types is created on the fly.
    MethodBuilder^ meth = tb->DefineMethod(
        "MyMethod", 
        MethodAttributes::Public, 
        int::typeid, 
        gcnew array<Type^> { int::typeid });

    ILGenerator^ methIL = meth->GetILGenerator();
    // To retrieve the private instance field, load the instance it
    // belongs to (argument zero). After loading the field, load the 
    // argument one and then multiply. Return from the method with 
    // the return value (the product of the two numbers) on the 
    // execution stack.
    methIL->Emit(OpCodes::Ldarg_0);
    methIL->Emit(OpCodes::Ldfld, fbNumber);
    methIL->Emit(OpCodes::Ldarg_1);
    methIL->Emit(OpCodes::Mul);
    methIL->Emit(OpCodes::Ret);

    // Finish the type->
    Type^ t = tb->CreateType();

    // Because AssemblyBuilderAccess includes Run, the code can be
    // executed immediately. Start by getting reflection objects for
    // the method and the property.
    MethodInfo^ mi = t->GetMethod("MyMethod");
    PropertyInfo^ pi = t->GetProperty("Number");
  
    // Create an instance of MyDynamicType using the default 
    // constructor. 
    Object^ o1 = Activator::CreateInstance(t);

    // Display the value of the property, then change it to 127 and 
    // display it again. Use nullptr to indicate that the property
    // has no index.
    Console::WriteLine("o1->Number: {0}", pi->GetValue(o1, nullptr));
    pi->SetValue(o1, 127, nullptr);
    Console::WriteLine("o1->Number: {0}", pi->GetValue(o1, nullptr));

    // Call MyMethod, passing 22, and display the return value, 22
    // times 127. Arguments must be passed as an array, even when
    // there is only one.
    array<Object^>^ arguments = { 22 };
    Console::WriteLine("o1->MyMethod(22): {0}", 
        mi->Invoke(o1, arguments));

    // Create an instance of MyDynamicType using the constructor
    // that specifies m_Number. The constructor is identified by
    // matching the types in the argument array. In this case, 
    // the argument array is created on the fly. Display the 
    // property value.
    Object^ o2 = Activator::CreateInstance(t, 
        gcnew array<Object^> { 5280 });
    Console::WriteLine("o2->Number: {0}", pi->GetValue(o2, nullptr));
};

/* This code produces the following output:

o1->Number: 42
o1->Number: 127
o1->MyMethod(22): 2794
o2->Number: 5280
 */
using System;
using System.Reflection;
using System.Reflection.Emit;

class DemoAssemblyBuilder
{
    public static void Main()
    {
        // This code creates an assembly that contains one type,
        // named "MyDynamicType", that has a private field, a property
        // that gets and sets the private field, constructors that
        // initialize the private field, and a method that multiplies
        // a user-supplied number by the private field value and returns
        // the result. In C# the type might look like this:
        /*
        public class MyDynamicType
        {
            private int m_number;

            public MyDynamicType() : this(42) {}
            public MyDynamicType(int initNumber)
            {
                m_number = initNumber;
            }

            public int Number
            {
                get { return m_number; }
                set { m_number = value; }
            }

            public int MyMethod(int multiplier)
            {
                return m_number * multiplier;
            }
        }
        */

        var aName = new AssemblyName("DynamicAssemblyExample");
        AssemblyBuilder ab =
            AssemblyBuilder.DefineDynamicAssembly(
                aName,
                AssemblyBuilderAccess.Run);

        // The module name is usually the same as the assembly name.
        ModuleBuilder mb = ab.DefineDynamicModule(aName.Name ?? "DynamicAssemblyExample");

        TypeBuilder tb = mb.DefineType(
            "MyDynamicType",
             TypeAttributes.Public);

        // Add a private field of type int (Int32).
        FieldBuilder fbNumber = tb.DefineField(
            "m_number",
            typeof(int),
            FieldAttributes.Private);

        // Define a constructor that takes an integer argument and
        // stores it in the private field.
        Type[] parameterTypes = { typeof(int) };
        ConstructorBuilder ctor1 = tb.DefineConstructor(
            MethodAttributes.Public,
            CallingConventions.Standard,
            parameterTypes);

        ILGenerator ctor1IL = ctor1.GetILGenerator();
        // For a constructor, argument zero is a reference to the new
        // instance. Push it on the stack before calling the base
        // class constructor. Specify the default constructor of the
        // base class (System.Object) by passing an empty array of
        // types (Type.EmptyTypes) to GetConstructor.
        ctor1IL.Emit(OpCodes.Ldarg_0);
        ConstructorInfo? ci = typeof(object).GetConstructor(Type.EmptyTypes);
        ctor1IL.Emit(OpCodes.Call, ci!);
        // Push the instance on the stack before pushing the argument
        // that is to be assigned to the private field m_number.
        ctor1IL.Emit(OpCodes.Ldarg_0);
        ctor1IL.Emit(OpCodes.Ldarg_1);
        ctor1IL.Emit(OpCodes.Stfld, fbNumber);
        ctor1IL.Emit(OpCodes.Ret);

        // Define a default constructor that supplies a default value
        // for the private field. For parameter types, pass the empty
        // array of types or pass null.
        ConstructorBuilder ctor0 = tb.DefineConstructor(
            MethodAttributes.Public,
            CallingConventions.Standard,
            Type.EmptyTypes);

        ILGenerator ctor0IL = ctor0.GetILGenerator();
        // For a constructor, argument zero is a reference to the new
        // instance. Push it on the stack before pushing the default
        // value on the stack, then call constructor ctor1.
        ctor0IL.Emit(OpCodes.Ldarg_0);
        ctor0IL.Emit(OpCodes.Ldc_I4_S, 42);
        ctor0IL.Emit(OpCodes.Call, ctor1);
        ctor0IL.Emit(OpCodes.Ret);

        // Define a property named Number that gets and sets the private
        // field.
        //
        // The last argument of DefineProperty is null, because the
        // property has no parameters. (If you don't specify null, you must
        // specify an array of Type objects. For a parameterless property,
        // use the built-in array with no elements: Type.EmptyTypes)
        PropertyBuilder pbNumber = tb.DefineProperty(
            "Number",
            PropertyAttributes.HasDefault,
            typeof(int),
            null);

        // The property "set" and property "get" methods require a special
        // set of attributes.
        MethodAttributes getSetAttr = MethodAttributes.Public |
            MethodAttributes.SpecialName | MethodAttributes.HideBySig;

        // Define the "get" accessor method for Number. The method returns
        // an integer and has no arguments. (Note that null could be
        // used instead of Types.EmptyTypes)
        MethodBuilder mbNumberGetAccessor = tb.DefineMethod(
            "get_Number",
            getSetAttr,
            typeof(int),
            Type.EmptyTypes);

        ILGenerator numberGetIL = mbNumberGetAccessor.GetILGenerator();
        // For an instance property, argument zero is the instance. Load the
        // instance, then load the private field and return, leaving the
        // field value on the stack.
        numberGetIL.Emit(OpCodes.Ldarg_0);
        numberGetIL.Emit(OpCodes.Ldfld, fbNumber);
        numberGetIL.Emit(OpCodes.Ret);

        // Define the "set" accessor method for Number, which has no return
        // type and takes one argument of type int (Int32).
        MethodBuilder mbNumberSetAccessor = tb.DefineMethod(
            "set_Number",
            getSetAttr,
            null,
            new Type[] { typeof(int) });

        ILGenerator numberSetIL = mbNumberSetAccessor.GetILGenerator();
        // Load the instance and then the numeric argument, then store the
        // argument in the field.
        numberSetIL.Emit(OpCodes.Ldarg_0);
        numberSetIL.Emit(OpCodes.Ldarg_1);
        numberSetIL.Emit(OpCodes.Stfld, fbNumber);
        numberSetIL.Emit(OpCodes.Ret);

        // Last, map the "get" and "set" accessor methods to the
        // PropertyBuilder. The property is now complete.
        pbNumber.SetGetMethod(mbNumberGetAccessor);
        pbNumber.SetSetMethod(mbNumberSetAccessor);

        // Define a method that accepts an integer argument and returns
        // the product of that integer and the private field m_number. This
        // time, the array of parameter types is created on the fly.
        MethodBuilder meth = tb.DefineMethod(
            "MyMethod",
            MethodAttributes.Public,
            typeof(int),
            new Type[] { typeof(int) });

        ILGenerator methIL = meth.GetILGenerator();
        // To retrieve the private instance field, load the instance it
        // belongs to (argument zero). After loading the field, load the
        // argument one and then multiply. Return from the method with
        // the return value (the product of the two numbers) on the
        // execution stack.
        methIL.Emit(OpCodes.Ldarg_0);
        methIL.Emit(OpCodes.Ldfld, fbNumber);
        methIL.Emit(OpCodes.Ldarg_1);
        methIL.Emit(OpCodes.Mul);
        methIL.Emit(OpCodes.Ret);

        // Finish the type.
        Type? t = tb.CreateType();

        // Because AssemblyBuilderAccess includes Run, the code can be
        // executed immediately. Start by getting reflection objects for
        // the method and the property.
        MethodInfo? mi = t?.GetMethod("MyMethod");
        PropertyInfo? pi = t?.GetProperty("Number");

        // Create an instance of MyDynamicType using the default
        // constructor.
        object? o1 = null;
        if (t is not null)
            o1 = Activator.CreateInstance(t);

        // Display the value of the property, then change it to 127 and
        // display it again. Use null to indicate that the property
        // has no index.
        Console.WriteLine("o1.Number: {0}", pi?.GetValue(o1, null));
        pi?.SetValue(o1, 127, null);
        Console.WriteLine("o1.Number: {0}", pi?.GetValue(o1, null));

        // Call MyMethod, passing 22, and display the return value, 22
        // times 127. Arguments must be passed as an array, even when
        // there is only one.
        object[] arguments = { 22 };
        Console.WriteLine("o1.MyMethod(22): {0}",
            mi?.Invoke(o1, arguments));

        // Create an instance of MyDynamicType using the constructor
        // that specifies m_Number. The constructor is identified by
        // matching the types in the argument array. In this case,
        // the argument array is created on the fly. Display the
        // property value.
        object? o2 = null;
        if (t is not null)
            Activator.CreateInstance(t, new object[] { 5280 });
        Console.WriteLine("o2.Number: {0}", pi?.GetValue(o2, null));
    }
}

/* This code produces the following output:

o1.Number: 42
o1.Number: 127
o1.MyMethod(22): 2794
o2.Number: 5280
 */
open System
open System.Threading
open System.Reflection
open System.Reflection.Emit

// This code creates an assembly that contains one type,
// named "MyDynamicType", that has a private field, a property
// that gets and sets the private field, constructors that
// initialize the private field, and a method that multiplies
// a user-supplied number by the private field value and returns
// the result. In C# the type might look like this:
(*
public class MyDynamicType
{
    private int m_number;

    public MyDynamicType() : this(42) {}
    public MyDynamicType(int initNumber)
    {
        m_number = initNumber;
    }

    public int Number
    {
        get { return m_number; }
        set { m_number = value; }
    }

    public int MyMethod(int multiplier)
    {
        return m_number * multiplier;
    }
}
*)

let assemblyName = new AssemblyName("DynamicAssemblyExample")
let assemblyBuilder =
    AssemblyBuilder.DefineDynamicAssembly(
        assemblyName,
        AssemblyBuilderAccess.Run)

// The module name is usually the same as the assembly name.
let moduleBuilder =
    assemblyBuilder.DefineDynamicModule(assemblyName.Name)

let typeBuilder =
    moduleBuilder.DefineType(
        "MyDynamicType",
        TypeAttributes.Public)

// Add a private field of type int (Int32)
let fieldBuilderNumber =
    typeBuilder.DefineField(
        "m_number",
        typeof<int>,
        FieldAttributes.Private)

// Define a constructor1 that takes an integer argument and
// stores it in the private field.
let parameterTypes = [| typeof<int> |]
let ctor1 =
    typeBuilder.DefineConstructor(
        MethodAttributes.Public,
        CallingConventions.Standard,
        parameterTypes)

let ctor1IL = ctor1.GetILGenerator()

// For a constructor, argument zero is a reference to the new
// instance. Push it on the stack before calling the base
// class constructor. Specify the default constructor of the
// base class (System.Object) by passing an empty array of
// types (Type.EmptyTypes) to GetConstructor.
ctor1IL.Emit(OpCodes.Ldarg_0)
ctor1IL.Emit(OpCodes.Call,
                 typeof<obj>.GetConstructor(Type.EmptyTypes))

// Push the instance on the stack before pushing the argument
// that is to be assigned to the private field m_number.
ctor1IL.Emit(OpCodes.Ldarg_0)
ctor1IL.Emit(OpCodes.Ldarg_1)
ctor1IL.Emit(OpCodes.Stfld, fieldBuilderNumber)
ctor1IL.Emit(OpCodes.Ret)

// Define a default constructor1 that supplies a default value
// for the private field. For parameter types, pass the empty
// array of types or pass null.
let ctor0 =
    typeBuilder.DefineConstructor(
        MethodAttributes.Public,
        CallingConventions.Standard,
        Type.EmptyTypes)

let ctor0IL = ctor0.GetILGenerator()
// For a constructor, argument zero is a reference to the new
// instance. Push it on the stack before pushing the default
// value on the stack, then call constructor ctor1.
ctor0IL.Emit(OpCodes.Ldarg_0)
ctor0IL.Emit(OpCodes.Ldc_I4_S, 42)
ctor0IL.Emit(OpCodes.Call, ctor1)
ctor0IL.Emit(OpCodes.Ret)

// Define a property named Number that gets and sets the private
// field.
//
// The last argument of DefineProperty is null, because the
// property has no parameters. (If you don't specify null, you must
// specify an array of Type objects. For a parameterless property,
// use the built-in array with no elements: Type.EmptyTypes)
let propertyBuilderNumber =
    typeBuilder.DefineProperty(
        "Number",
        PropertyAttributes.HasDefault,
        typeof<int>,
        null)

// The property "set" and property "get" methods require a special
// set of attributes.
let getSetAttr = MethodAttributes.Public ||| MethodAttributes.SpecialName ||| MethodAttributes.HideBySig

// Define the "get" accessor method for Number. The method returns
// an integer and has no arguments. (Note that null could be
// used instead of Types.EmptyTypes)
let methodBuilderNumberGetAccessor =
    typeBuilder.DefineMethod(
        "get_number",
        getSetAttr,
        typeof<int>,
        Type.EmptyTypes)

let numberGetIL =
    methodBuilderNumberGetAccessor.GetILGenerator()

// For an instance property, argument zero ir the instance. Load the
// instance, then load the private field and return, leaving the
// field value on the stack.
numberGetIL.Emit(OpCodes.Ldarg_0)
numberGetIL.Emit(OpCodes.Ldfld, fieldBuilderNumber)
numberGetIL.Emit(OpCodes.Ret)

// Define the "set" accessor method for Number, which has no return
// type and takes one argument of type int (Int32).
let methodBuilderNumberSetAccessor =
    typeBuilder.DefineMethod(
        "set_number",
        getSetAttr,
        null,
        [| typeof<int> |])

let numberSetIL =
    methodBuilderNumberSetAccessor.GetILGenerator()
// Load the instance and then the numeric argument, then store the
// argument in the field
numberSetIL.Emit(OpCodes.Ldarg_0)
numberSetIL.Emit(OpCodes.Ldarg_1)
numberSetIL.Emit(OpCodes.Stfld, fieldBuilderNumber)
numberSetIL.Emit(OpCodes.Ret)

// Last, map the "get" and "set" accessor methods to the
// PropertyBuilder. The property is now complete.
propertyBuilderNumber.SetGetMethod(methodBuilderNumberGetAccessor)
propertyBuilderNumber.SetSetMethod(methodBuilderNumberSetAccessor)

// Define a method that accepts an integer argument and returns
// the product of that integer and the private field m_number. This
// time, the array of parameter types is created on the fly.
let methodBuilder =
    typeBuilder.DefineMethod(
        "MyMethod",
        MethodAttributes.Public,
        typeof<int>,
        [| typeof<int> |])

let methodIL = methodBuilder.GetILGenerator()
// To retrieve the private instance field, load the instance it
// belongs to (argument zero). After loading the field, load the
// argument one and then multiply. Return from the method with
// the return value (the product of the two numbers) on the
// execution stack.
methodIL.Emit(OpCodes.Ldarg_0)
methodIL.Emit(OpCodes.Ldfld, fieldBuilderNumber)
methodIL.Emit(OpCodes.Ldarg_1)
methodIL.Emit(OpCodes.Mul)
methodIL.Emit(OpCodes.Ret)

// Finish the type
let typ = typeBuilder.CreateType()

// Because AssemblyBuilderAccess includes Run, the code can be
// executed immediately. Start by getting reflection objects for
// the method and the property.
let methodInfo = typ.GetMethod("MyMethod")
let propertyInfo = typ.GetProperty("Number")

// Create an instance of MyDynamicType using the default
// constructor.
let obj1 = Activator.CreateInstance(typ)

// Display the value of the property, then change it to 127 and
// display it again. Use null to indicate that the property
// has no index.
printfn "obj1.Number: %A" (propertyInfo.GetValue(obj1, null))
propertyInfo.SetValue(obj1, 127, null)
printfn "obj1.Number: %A" (propertyInfo.GetValue(obj1, null))

// Call MyMethod, pasing 22, and display the return value, 22
// times 127. Arguments must be passed as an array, even when
// there is only one.
let arguments: obj array = [| 22 |]
printfn "obj1.MyMethod(22): %A" (methodInfo.Invoke(obj1, arguments))

// Create an instance of MyDynamicType using the constructor
// that specifies m_Number. The constructor is identified by
// matching the types in the argument array. In this case,
// the argument array is created on the fly. Display the
// property value.
let constructorArguments: obj array = [| 5280 |]
let obj2 = Activator.CreateInstance(typ, constructorArguments)
printfn "obj2.Number: %A" (propertyInfo.GetValue(obj2, null))

(* This code produces the following output:

obj1.Number: 42
obj1.Number: 127
obj1.MyMethod(22): 2794
obj1.Number: 5280
*)
Imports System.Reflection
Imports System.Reflection.Emit

Class DemoAssemblyBuilder

    Public Shared Sub Main()

        ' This code creates an assembly that contains one type,
        ' named "MyDynamicType", that has a private field, a property
        ' that gets and sets the private field, constructors that
        ' initialize the private field, and a method that multiplies
        ' a user-supplied number by the private field value and returns
        ' the result. The code might look like this in Visual Basic:
        '
        'Public Class MyDynamicType
        '    Private m_number As Integer
        '
        '    Public Sub New()
        '        Me.New(42)
        '    End Sub
        '
        '    Public Sub New(ByVal initNumber As Integer)
        '        m_number = initNumber
        '    End Sub
        '
        '    Public Property Number As Integer
        '        Get
        '            Return m_number
        '        End Get
        '        Set
        '            m_Number = Value
        '        End Set
        '    End Property
        '
        '    Public Function MyMethod(ByVal multiplier As Integer) As Integer
        '        Return m_Number * multiplier
        '    End Function
        'End Class
      
        Dim aName As New AssemblyName("DynamicAssemblyExample")
        Dim ab As AssemblyBuilder = _
            AssemblyBuilder.DefineDynamicAssembly( _
                aName, _
                AssemblyBuilderAccess.Run)

        ' The module name is usually the same as the assembly name.
        Dim mb As ModuleBuilder = ab.DefineDynamicModule( _
            aName.Name)
      
        Dim tb As TypeBuilder = _
            mb.DefineType("MyDynamicType", TypeAttributes.Public)

        ' Add a private field of type Integer (Int32).
        Dim fbNumber As FieldBuilder = tb.DefineField( _
            "m_number", _
            GetType(Integer), _
            FieldAttributes.Private)

        ' Define a constructor that takes an integer argument and 
        ' stores it in the private field. 
        Dim parameterTypes() As Type = { GetType(Integer) }
        Dim ctor1 As ConstructorBuilder = _
            tb.DefineConstructor( _
                MethodAttributes.Public, _
                CallingConventions.Standard, _
                parameterTypes)

        Dim ctor1IL As ILGenerator = ctor1.GetILGenerator()
        ' For a constructor, argument zero is a reference to the new
        ' instance. Push it on the stack before calling the base
        ' class constructor. Specify the default constructor of the 
        ' base class (System.Object) by passing an empty array of 
        ' types (Type.EmptyTypes) to GetConstructor.
        ctor1IL.Emit(OpCodes.Ldarg_0)
        ctor1IL.Emit(OpCodes.Call, _
            GetType(Object).GetConstructor(Type.EmptyTypes))
        ' Push the instance on the stack before pushing the argument
        ' that is to be assigned to the private field m_number.
        ctor1IL.Emit(OpCodes.Ldarg_0)
        ctor1IL.Emit(OpCodes.Ldarg_1)
        ctor1IL.Emit(OpCodes.Stfld, fbNumber)
        ctor1IL.Emit(OpCodes.Ret)

        ' Define a default constructor that supplies a default value
        ' for the private field. For parameter types, pass the empty
        ' array of types or pass Nothing.
        Dim ctor0 As ConstructorBuilder = tb.DefineConstructor( _
            MethodAttributes.Public, _
            CallingConventions.Standard, _
            Type.EmptyTypes)

        Dim ctor0IL As ILGenerator = ctor0.GetILGenerator()
        ' For a constructor, argument zero is a reference to the new
        ' instance. Push it on the stack before pushing the default
        ' value on the stack, then call constructor ctor1.
        ctor0IL.Emit(OpCodes.Ldarg_0)
        ctor0IL.Emit(OpCodes.Ldc_I4_S, 42)
        ctor0IL.Emit(OpCodes.Call, ctor1)
        ctor0IL.Emit(OpCodes.Ret)

        ' Define a property named Number that gets and sets the private 
        ' field.
        '
        ' The last argument of DefineProperty is Nothing, because the
        ' property has no parameters. (If you don't specify Nothing, you must
        ' specify an array of Type objects. For a parameterless property,
        ' use the built-in array with no elements: Type.EmptyTypes)
        Dim pbNumber As PropertyBuilder = tb.DefineProperty( _
            "Number", _
            PropertyAttributes.HasDefault, _
            GetType(Integer), _
            Nothing)
      
        ' The property Set and property Get methods require a special
        ' set of attributes.
        Dim getSetAttr As MethodAttributes = _
            MethodAttributes.Public Or MethodAttributes.SpecialName _
                Or MethodAttributes.HideBySig

        ' Define the "get" accessor method for Number. The method returns
        ' an integer and has no arguments. (Note that Nothing could be 
        ' used instead of Types.EmptyTypes)
        Dim mbNumberGetAccessor As MethodBuilder = tb.DefineMethod( _
            "get_Number", _
            getSetAttr, _
            GetType(Integer), _
            Type.EmptyTypes)
      
        Dim numberGetIL As ILGenerator = mbNumberGetAccessor.GetILGenerator()
        ' For an instance property, argument zero is the instance. Load the 
        ' instance, then load the private field and return, leaving the
        ' field value on the stack.
        numberGetIL.Emit(OpCodes.Ldarg_0)
        numberGetIL.Emit(OpCodes.Ldfld, fbNumber)
        numberGetIL.Emit(OpCodes.Ret)
        
        ' Define the "set" accessor method for Number, which has no return
        ' type and takes one argument of type Integer (Int32).
        Dim mbNumberSetAccessor As MethodBuilder = _
            tb.DefineMethod( _
                "set_Number", _
                getSetAttr, _
                Nothing, _
                New Type() { GetType(Integer) })
      
        Dim numberSetIL As ILGenerator = mbNumberSetAccessor.GetILGenerator()
        ' Load the instance and then the numeric argument, then store the
        ' argument in the field.
        numberSetIL.Emit(OpCodes.Ldarg_0)
        numberSetIL.Emit(OpCodes.Ldarg_1)
        numberSetIL.Emit(OpCodes.Stfld, fbNumber)
        numberSetIL.Emit(OpCodes.Ret)
      
        ' Last, map the "get" and "set" accessor methods to the 
        ' PropertyBuilder. The property is now complete. 
        pbNumber.SetGetMethod(mbNumberGetAccessor)
        pbNumber.SetSetMethod(mbNumberSetAccessor)

        ' Define a method that accepts an integer argument and returns
        ' the product of that integer and the private field m_number. This
        ' time, the array of parameter types is created on the fly.
        Dim meth As MethodBuilder = tb.DefineMethod( _
            "MyMethod", _
            MethodAttributes.Public, _
            GetType(Integer), _
            New Type() { GetType(Integer) })

        Dim methIL As ILGenerator = meth.GetILGenerator()
        ' To retrieve the private instance field, load the instance it
        ' belongs to (argument zero). After loading the field, load the 
        ' argument one and then multiply. Return from the method with 
        ' the return value (the product of the two numbers) on the 
        ' execution stack.
        methIL.Emit(OpCodes.Ldarg_0)
        methIL.Emit(OpCodes.Ldfld, fbNumber)
        methIL.Emit(OpCodes.Ldarg_1)
        methIL.Emit(OpCodes.Mul)
        methIL.Emit(OpCodes.Ret)

        ' Finish the type.
        Dim t As Type = tb.CreateType()

        ' Because AssemblyBuilderAccess includes Run, the code can be
        ' executed immediately. Start by getting reflection objects for
        ' the method and the property.
        Dim mi As MethodInfo = t.GetMethod("MyMethod")
        Dim pi As PropertyInfo = t.GetProperty("Number")
  
        ' Create an instance of MyDynamicType using the default 
        ' constructor. 
        Dim o1 As Object = Activator.CreateInstance(t)

        ' Display the value of the property, then change it to 127 and 
        ' display it again. Use Nothing to indicate that the property
        ' has no index.
        Console.WriteLine("o1.Number: {0}", pi.GetValue(o1, Nothing))
        pi.SetValue(o1, 127, Nothing)
        Console.WriteLine("o1.Number: {0}", pi.GetValue(o1, Nothing))

        ' Call MyMethod, passing 22, and display the return value, 22
        ' times 127. Arguments must be passed as an array, even when
        ' there is only one.
        Dim arguments() As Object = { 22 }
        Console.WriteLine("o1.MyMethod(22): {0}", _
            mi.Invoke(o1, arguments))

        ' Create an instance of MyDynamicType using the constructor
        ' that specifies m_Number. The constructor is identified by
        ' matching the types in the argument array. In this case, 
        ' the argument array is created on the fly. Display the 
        ' property value.
        Dim o2 As Object = Activator.CreateInstance(t, _
            New Object() { 5280 })
        Console.WriteLine("o2.Number: {0}", pi.GetValue(o2, Nothing))
      
    End Sub  
End Class

' This code produces the following output:
'
'o1.Number: 42
'o1.Number: 127
'o1.MyMethod(22): 2794
'o2.Number: 5280

Poznámky

Další informace o tomto rozhraní API najdete v tématu Doplňkové poznámky k rozhraní API pro AssemblyBuilder.

Konstruktory

AssemblyBuilder()

Inicializuje novou instanci AssemblyBuilder třídy .

Vlastnosti

CodeBase
Zastaralé.

Získá umístění sestavení, jak bylo původně zadáno (například v objektu AssemblyName ).

CodeBase
Zastaralé.
Zastaralé.

Získá umístění sestavení, jak bylo původně zadáno, například v objektu AssemblyName .

(Zděděno od Assembly)
CustomAttributes

Získá kolekci, která obsahuje vlastní atributy tohoto sestavení.

(Zděděno od Assembly)
DefinedTypes

Definuje a představuje dynamické sestavení.

DefinedTypes

Získá kolekci typů definovaných v tomto sestavení.

(Zděděno od Assembly)
EntryPoint

Vrátí vstupní bod tohoto sestavení.

EntryPoint

Získá vstupní bod tohoto sestavení.

(Zděděno od Assembly)
EscapedCodeBase
Zastaralé.
Zastaralé.

Získá identifikátor URI včetně řídicích znaků, který představuje základ kódu.

(Zděděno od Assembly)
Evidence

Získá důkazy pro toto sestavení.

Evidence

Získá důkazy pro toto sestavení.

(Zděděno od Assembly)
ExportedTypes

Získá kolekci veřejných typů definovaných v tomto sestavení, které jsou viditelné mimo sestavení.

(Zděděno od Assembly)
FullName

Získá zobrazovaný název aktuální dynamické sestavení.

FullName

Získá zobrazovaný název sestavení.

(Zděděno od Assembly)
GlobalAssemblyCache
Zastaralé.

Získá hodnotu, která označuje, zda sestavení bylo načteno z globální mezipaměti sestavení.

GlobalAssemblyCache
Zastaralé.

Získá hodnotu určující, zda sestavení bylo načteno z globální mezipaměti sestavení (pouze rozhraní .NET Framework).

(Zděděno od Assembly)
HostContext

Získá kontext hostitele, kde se vytváří dynamické sestavení.

HostContext

Získá kontext hostitele, se kterým bylo sestavení načteno.

(Zděděno od Assembly)
ImageRuntimeVersion

Získá verzi modulu CLR (Common Language Runtime), který bude uložen v souboru obsahujícím manifest.

ImageRuntimeVersion

Získá řetězec představující verzi modulu CLR (Common Language Runtime) uloženého v souboru obsahujícím manifest.

(Zděděno od Assembly)
IsCollectible

Získá hodnotu, která označuje, zda toto dynamické sestavení je uložen v collectible AssemblyLoadContext.

IsCollectible

Získá hodnotu, která označuje, zda je toto sestavení uložena v collectible AssemblyLoadContext.

(Zděděno od Assembly)
IsDynamic

Získá hodnotu, která označuje, že aktuální sestavení je dynamické sestavení.

IsDynamic

Získá hodnotu, která označuje, zda aktuální sestavení bylo vygenerováno dynamicky v aktuálním procesu pomocí reflexe emit.

(Zděděno od Assembly)
IsFullyTrusted

Získá hodnotu, která označuje, zda aktuální sestavení je načtena s úplný vztah důvěryhodnosti.

(Zděděno od Assembly)
Location

Získá umístění ve formátu základu kódu načteného souboru, který obsahuje manifest, pokud není stínově zkopírován.

Location

Získá úplnou cestu nebo umístění UNC načteného souboru, který obsahuje manifest.

(Zděděno od Assembly)
ManifestModule

Získá modul v aktuálním AssemblyBuilder , který obsahuje manifest sestavení.

ManifestModule

Získá modul, který obsahuje manifest pro aktuální sestavení.

(Zděděno od Assembly)
Modules

Definuje a představuje dynamické sestavení.

Modules

Získá kolekci, která obsahuje moduly v tomto sestavení.

(Zděděno od Assembly)
PermissionSet

Získá sadu grantů aktuální dynamické sestavení.

PermissionSet

Získá sadu udělení aktuálního sestavení.

(Zděděno od Assembly)
ReflectionOnly

Získá hodnotu označující, zda dynamické sestavení je v kontextu pouze reflexe.

ReflectionOnly

Boolean Získá hodnotu označující, zda bylo toto sestavení načteno do kontextu pouze reflexe.

(Zděděno od Assembly)
SecurityRuleSet

Získá hodnotu, která označuje, která sada pravidel zabezpečení common language runtime (CLR) vynucuje pro toto sestavení.

SecurityRuleSet

Získá hodnotu, která označuje sadu pravidel zabezpečení common language runtime (CLR) vynucuje pro toto sestavení.

(Zděděno od Assembly)

Metody

AddResourceFile(String, String)

Přidá existující soubor prostředků do tohoto sestavení.

AddResourceFile(String, String, ResourceAttributes)

Přidá existující soubor prostředků do tohoto sestavení.

CreateInstance(String)

Vyhledá zadaný typ z tohoto sestavení a vytvoří jeho instanci pomocí aktivátoru systému pomocí vyhledávání s rozlišováním velkých a malých písmen.

(Zděděno od Assembly)
CreateInstance(String, Boolean)

Vyhledá zadaný typ z tohoto sestavení a vytvoří jeho instanci pomocí aktivátoru systému s volitelným vyhledáváním rozlišující malá a velká písmena.

(Zděděno od Assembly)
CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])

Vyhledá zadaný typ z tohoto sestavení a vytvoří jeho instanci pomocí aktivátoru systému s volitelným vyhledáváním s rozlišováním velkých a malých písmen a má zadanou jazykovou verzi, argumenty a vazby a aktivační atributy.

(Zděděno od Assembly)
DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess)

Definuje dynamické sestavení, které má zadaný název a přístupová práva.

DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)

Definuje nové sestavení, které má zadaný název, přístupová práva a atributy.

DefineDynamicModule(String)

Definuje pojmenovaný přechodný dynamický modul v tomto sestavení.

DefineDynamicModule(String, Boolean)

Definuje pojmenovaný přechodný dynamický modul v tomto sestavení a určuje, zda mají být generovány informace o symbolech.

DefineDynamicModule(String, String)

Definuje trvalý dynamický modul s daným názvem, který se uloží do zadaného souboru. Negenerují se žádné informace o symbolech.

DefineDynamicModule(String, String, Boolean)

Definuje trvalý dynamický modul, který určuje název modulu, název souboru, do kterého bude modul uložen, a zda mají být informace o symbolech generovány pomocí výchozího zapisovače symbolů.

DefineDynamicModuleCore(String)

Při přepsání v odvozené třídě definuje dynamický modul v tomto sestavení.

DefinePersistedAssembly(AssemblyName, Assembly, IEnumerable<CustomAttributeBuilder>)

Definuje a představuje dynamické sestavení.

DefineResource(String, String, String)

Definuje samostatný spravovaný prostředek pro toto sestavení s výchozím atributem veřejného prostředku.

DefineResource(String, String, String, ResourceAttributes)

Definuje samostatný spravovaný prostředek pro toto sestavení. Pro spravovaný prostředek je možné zadat atributy.

DefineUnmanagedResource(Byte[])

Definuje nespravovaný prostředek pro toto sestavení jako neprůsažný objekt blob bajtů.

DefineUnmanagedResource(String)

Definuje nespravovaný soubor prostředků pro toto sestavení s názvem souboru prostředků.

DefineVersionInfoResource()

Definuje nespravovaný zdroj informací o verzi pomocí informací zadaných v objektu AssemblyName sestavení a vlastních atributů sestavení.

DefineVersionInfoResource(String, String, String, String, String)

Definuje nespravovaný zdroj informací o verzi pro toto sestavení se zadanými specifikacemi.

Equals(Object)

Vrátí hodnotu, která označuje, zda se tato instance rovná zadanému objektu.

Equals(Object)

Určuje, zda je toto sestavení a zadaný objekt stejné.

(Zděděno od Assembly)
GetCustomAttributes(Boolean)

Vrátí všechny vlastní atributy, které byly použity pro aktuální AssemblyBuilder.

GetCustomAttributes(Boolean)

Získá všechny vlastní atributy pro toto sestavení.

(Zděděno od Assembly)
GetCustomAttributes(Type, Boolean)

Vrátí všechny vlastní atributy, které byly použity pro aktuální AssemblyBuildera které jsou odvozeny ze zadaného typu atributu.

GetCustomAttributes(Type, Boolean)

Získá vlastní atributy pro toto sestavení, jak je určeno typem.

(Zděděno od Assembly)
GetCustomAttributesData()

Vrátí CustomAttributeData objekty obsahující informace o atributech, které byly použity pro aktuální AssemblyBuilder.

GetCustomAttributesData()

Vrátí informace o atributech, které byly použity na aktuální Assembly, vyjádřené jako CustomAttributeData objekty.

(Zděděno od Assembly)
GetDynamicModule(String)

Vrátí dynamický modul se zadaným názvem.

GetDynamicModuleCore(String)

Při přepsání v odvozené třídě vrátí dynamický modul se zadaným názvem.

GetExportedTypes()

Získá exportované typy definované v tomto sestavení.

GetExportedTypes()

Získá veřejné typy definované v tomto sestavení, které jsou viditelné mimo sestavení.

(Zděděno od Assembly)
GetFile(String)

Získá pro FileStream zadaný soubor v tabulce souborů manifestu tohoto sestavení.

GetFile(String)

FileStream Získá pro zadaný soubor v tabulce souborů manifestu tohoto sestavení.

(Zděděno od Assembly)
GetFiles()

Získá soubory v tabulce souborů manifestu sestavení.

(Zděděno od Assembly)
GetFiles(Boolean)

Získá soubory v tabulce souborů manifestu sestavení a určí, zda zahrnout moduly prostředků.

GetFiles(Boolean)

Získá soubory v tabulce souborů manifestu sestavení a určí, zda mají být zahrnuty moduly prostředků.

(Zděděno od Assembly)
GetForwardedTypes()

Definuje a představuje dynamické sestavení.

(Zděděno od Assembly)
GetHashCode()

Vrátí hodnotu hash pro tuto instanci.

GetHashCode()

Vrátí hodnotu hash pro tuto instanci.

(Zděděno od Assembly)
GetLoadedModules()

Získá všechny načtené moduly, které jsou součástí tohoto sestavení.

(Zděděno od Assembly)
GetLoadedModules(Boolean)

Vrátí všechny načtené moduly, které jsou součástí tohoto sestavení, a volitelně zahrnuje moduly prostředků.

GetLoadedModules(Boolean)

Získá všechny načtené moduly, které jsou součástí tohoto sestavení, a určuje, zda mají být zahrnuty moduly prostředků.

(Zděděno od Assembly)
GetManifestResourceInfo(String)

Vrátí informace o tom, jak byl daný prostředek trvale zachován.

GetManifestResourceNames()

Načte zadaný prostředek manifestu z tohoto sestavení.

GetManifestResourceStream(String)

Načte zadaný prostředek manifestu z tohoto sestavení.

GetManifestResourceStream(Type, String)

Z tohoto sestavení načte zadaný prostředek manifestu vymezený oborem názvů zadaného typu.

GetManifestResourceStream(Type, String)

Načte zadaný prostředek manifestu vymezený oborem názvů zadaného typu z tohoto sestavení.

(Zděděno od Assembly)
GetModule(String)

Získá zadaný modul v tomto sestavení.

GetModule(String)

Získá zadaný modul v tomto sestavení.

(Zděděno od Assembly)
GetModules()

Získá všechny moduly, které jsou součástí tohoto sestavení.

(Zděděno od Assembly)
GetModules(Boolean)

Získá všechny moduly, které jsou součástí tohoto sestavení, a volitelně zahrnuje moduly prostředků.

GetModules(Boolean)

Získá všechny moduly, které jsou součástí tohoto sestavení, a určí, zda mají být zahrnuty moduly prostředků.

(Zděděno od Assembly)
GetName()

Získá pro AssemblyName toto sestavení.

(Zděděno od Assembly)
GetName(Boolean)

AssemblyName Získá, který byl zadán při vytvoření aktuální dynamické sestavení, a nastaví kód základu, jak je zadáno.

GetName(Boolean)

Získá pro AssemblyName toto sestavení a nastaví základ kódu určený parametrem copiedName.

(Zděděno od Assembly)
GetObjectData(SerializationInfo, StreamingContext)
Zastaralé.

Získá serializační informace se všemi daty potřebnými k obnovení tohoto sestavení.

(Zděděno od Assembly)
GetReferencedAssemblies()

Získá neúplný seznam AssemblyName objektů pro sestavení, na které odkazuje tento AssemblyBuilder.

GetReferencedAssemblies()

AssemblyName Získá objekty pro všechna sestavení odkazovaná tímto sestavením.

(Zděděno od Assembly)
GetSatelliteAssembly(CultureInfo)

Získá satelitní sestavení pro zadanou jazykovou verzi.

GetSatelliteAssembly(CultureInfo)

Získá satelitní sestavení pro zadanou jazykovou verzi.

(Zděděno od Assembly)
GetSatelliteAssembly(CultureInfo, Version)

Získá zadanou verzi satelitního sestavení pro zadanou jazykovou verzi.

GetSatelliteAssembly(CultureInfo, Version)

Získá zadanou verzi satelitního sestavení pro zadanou jazykovou verzi.

(Zděděno od Assembly)
GetType()

Definuje a představuje dynamické sestavení.

(Zděděno od Assembly)
GetType(String)

Type Získá objekt se zadaným názvem v instanci sestavení.

(Zděděno od Assembly)
GetType(String, Boolean)

Type Získá objekt se zadaným názvem v instanci sestavení a volitelně vyvolá výjimku, pokud typ nebyl nalezen.

(Zděděno od Assembly)
GetType(String, Boolean, Boolean)

Získá zadaný typ z typů, které byly definovány a vytvořeny v aktuální AssemblyBuilder.

GetType(String, Boolean, Boolean)

Type Získá objekt se zadaným názvem v instanci sestavení s možnostmi ignorování případu a vyvolání výjimky, pokud typ nebyl nalezen.

(Zděděno od Assembly)
GetTypes()

Získá všechny typy definované v tomto sestavení.

(Zděděno od Assembly)
IsDefined(Type, Boolean)

Vrátí hodnotu, která označuje, zda je u tohoto člena použita jedna nebo více instancí zadaného typu atributu.

IsDefined(Type, Boolean)

Označuje, zda byl zadaný atribut použit na sestavení.

(Zděděno od Assembly)
LoadModule(String, Byte[])

Načte modul, interní k tomuto sestavení, s bitovou kopií založenou na formátu COFF (Common Object File Format), která obsahuje vygenerovaný modul nebo soubor prostředků.

(Zděděno od Assembly)
LoadModule(String, Byte[], Byte[])

Načte modul, interní k tomuto sestavení, s bitovou kopií založenou na formátu COFF (Common Object File Format), která obsahuje vygenerovaný modul nebo soubor prostředků. Načtou se také nezpracované bajty představující symboly modulu.

(Zděděno od Assembly)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
Save(Stream)

Definuje a představuje dynamické sestavení.

Save(String)

Uloží toto dynamické sestavení na disk.

Save(String, PortableExecutableKinds, ImageFileMachine)

Uloží toto dynamické sestavení na disk a určí povahu kódu v spustitelných souborech sestavení a cílové platformě.

SaveCore(Stream)

Definuje a představuje dynamické sestavení.

SetCustomAttribute(ConstructorInfo, Byte[])

Nastavte vlastní atribut v tomto sestavení pomocí zadaného objektu blob vlastního atributu.

SetCustomAttribute(CustomAttributeBuilder)

Nastavte vlastní atribut v tomto sestavení pomocí vlastního tvůrce atributů.

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

Při přepsání v odvozené třídě nastaví vlastní atribut v tomto sestavení.

SetEntryPoint(MethodInfo)

Nastaví vstupní bod pro toto dynamické sestavení za předpokladu, že se sestavuje konzolová aplikace.

SetEntryPoint(MethodInfo, PEFileKinds)

Nastaví vstupní bod pro toto sestavení a definuje typ vytvářeného přenosného spustitelného souboru (soubor PE).

ToString()

Vrátí úplný název sestavení, označovaný také jako zobrazovaný název.

(Zděděno od Assembly)

Událost

ModuleResolve

Nastane, když zavaděč třídy CLR (Common Language Runtime) nemůže přeložit odkaz na interní modul sestavení normálním způsobem.

(Zděděno od Assembly)

Explicitní implementace rozhraní

_Assembly.GetType()

Vrátí typ aktuální instance.

(Zděděno od Assembly)
_AssemblyBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání.

_AssemblyBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

Načte informace o typu objektu, který lze použít k získání informací o typu pro rozhraní.

_AssemblyBuilder.GetTypeInfoCount(UInt32)

Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1).

_AssemblyBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Poskytuje přístup k vlastnostem a metodám vystaveným objektem.

ICustomAttributeProvider.GetCustomAttributes(Boolean)

Vrátí pole všech vlastních atributů definovaných v tomto členu, s výjimkou pojmenovaných atributů, nebo prázdné pole, pokud neexistují žádné vlastní atributy.

(Zděděno od Assembly)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

Vrátí pole vlastních atributů definovaných v tomto členu, identifikované typem nebo prázdné pole, pokud neexistují žádné vlastní atributy tohoto typu.

(Zděděno od Assembly)
ICustomAttributeProvider.IsDefined(Type, Boolean)

Určuje, zda je u tohoto člena attributeType definována jedna nebo více instancí.

(Zděděno od Assembly)

Metody rozšíření

GetExportedTypes(Assembly)

Definuje a představuje dynamické sestavení.

GetModules(Assembly)

Definuje a představuje dynamické sestavení.

GetTypes(Assembly)

Definuje a představuje dynamické sestavení.

GetCustomAttribute(Assembly, Type)

Načte vlastní atribut zadaného typu, který je použit na zadané sestavení.

GetCustomAttribute<T>(Assembly)

Načte vlastní atribut zadaného typu, který je použit na zadané sestavení.

GetCustomAttributes(Assembly)

Načte kolekci vlastních atributů, které jsou použity na zadané sestavení.

GetCustomAttributes(Assembly, Type)

Načte kolekci vlastních atributů zadaného typu, které jsou použity na zadané sestavení.

GetCustomAttributes<T>(Assembly)

Načte kolekci vlastních atributů zadaného typu, které jsou použity na zadané sestavení.

IsDefined(Assembly, Type)

Určuje, zda vlastní atributy zadaného typu jsou použity na zadané sestavení.

TryGetRawMetadata(Assembly, Byte*, Int32)

Načte část metadat sestavení pro použití s MetadataReader.

Platí pro

Viz také