AssemblyBuilder 클래스

정의

동적 어셈블리를 정의하고 나타냅니다.

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
상속
AssemblyBuilder
특성
구현

예제

다음 코드 예제에서는 동적 어셈블리를 정의하고 사용하는 방법을 보여줍니다. 예제 어셈블리에는 프라이빗 필드가 있는 형식, MyDynamicType프라이빗 필드를 가져오고 설정하는 속성, 프라이빗 필드를 초기화하는 생성자 및 사용자가 제공한 숫자를 개인 필드 값으로 곱하고 결과를 반환하는 메서드가 포함됩니다.

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

설명

이 API에 대한 자세한 내용은 AssemblyBuilder에 대한 추가 API 설명을 참조하세요.

생성자

AssemblyBuilder()

AssemblyBuilder 클래스의 새 인스턴스를 초기화합니다.

속성

CodeBase
사용되지 않음.

원래 지정된 것처럼(예: AssemblyName 개체) 어셈블리의 위치를 가져옵니다.

CodeBase
사용되지 않음.
사용되지 않음.

예를 들어 AssemblyName 개체에 원래 지정된 어셈블리 위치를 가져옵니다.

(다음에서 상속됨 Assembly)
CustomAttributes

이 어셈블리의 사용자 지정 특성을 포함하는 컬렉션을 가져옵니다.

(다음에서 상속됨 Assembly)
DefinedTypes

동적 어셈블리를 정의하고 나타냅니다.

DefinedTypes

이 어셈블리에 정의된 형식의 컬렉션을 가져옵니다.

(다음에서 상속됨 Assembly)
EntryPoint

이 어셈블리의 진입점을 반환합니다.

EntryPoint

이 어셈블리의 진입점을 가져옵니다.

(다음에서 상속됨 Assembly)
EscapedCodeBase
사용되지 않음.
사용되지 않음.

코드베이스를 나타내는 URI를 가져옵니다(이스케이프 문자 포함).

(다음에서 상속됨 Assembly)
Evidence

이 어셈블리의 증명을 가져옵니다.

Evidence

이 어셈블리의 증명을 가져옵니다.

(다음에서 상속됨 Assembly)
ExportedTypes

이 어셈블리에 정의된 형식 중 어셈블리 외부에서 볼 수 있는 public 형식의 컬렉션을 가져옵니다.

(다음에서 상속됨 Assembly)
FullName

현재 동적 어셈블리의 표시 이름을 가져옵니다.

FullName

어셈블리의 표시 이름을 가져옵니다.

(다음에서 상속됨 Assembly)
GlobalAssemblyCache
사용되지 않음.

어셈블리가 전역 어셈블리 캐시에서 로드되었는지 여부를 나타내는 값을 가져옵니다.

GlobalAssemblyCache
사용되지 않음.

어셈블리가 전역 어셈블리 캐시에서 로드되었는지 여부를 나타내는 값을 가져옵니다(.NET Framework만 해당).

(다음에서 상속됨 Assembly)
HostContext

동적 어셈블리를 만드는 중인 호스트 컨텍스트를 가져옵니다.

HostContext

어셈블리를 로드하는 데 사용된 호스트 컨텍스트를 가져옵니다.

(다음에서 상속됨 Assembly)
ImageRuntimeVersion

매니페스트를 포함하는 파일에 저장될 공용 언어 런타임의 버전을 가져옵니다.

ImageRuntimeVersion

매니페스트가 포함된 파일에 저장된 CLR(공용 언어 런타임) 버전을 나타내는 문자열을 가져옵니다.

(다음에서 상속됨 Assembly)
IsCollectible

이 동적 어셈블리가 수집 가능한 AssemblyLoadContext에 보관되는지 여부를 나타내는 값을 가져옵니다.

IsCollectible

이 어셈블리가 수집 가능한 AssemblyLoadContext에 보관되어 있는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Assembly)
IsDynamic

현재 어셈블리가 동적 어셈블리임을 나타내는 값을 가져옵니다.

IsDynamic

현재 어셈블리가 현재 프로세스에서 리플렉션 내보내기를 사용하여 동적으로 생성되었는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Assembly)
IsFullyTrusted

현재 어셈블리가 완전히 신뢰되어 로드되는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Assembly)
Location

섀도 복사되지 않은 경우 매니페스트를 포함하는 로드된 파일의 위치를 코드베이스 형식으로 가져옵니다.

Location

매니페스트가 포함된 로드된 파일의 전체 경로나 UNC 위치를 가져옵니다.

(다음에서 상속됨 Assembly)
ManifestModule

어셈블리 매니페스트가 들어 있는 현재 AssemblyBuilder의 모듈을 가져옵니다.

ManifestModule

현재 어셈블리의 매니페스트가 포함된 모듈을 가져옵니다.

(다음에서 상속됨 Assembly)
Modules

동적 어셈블리를 정의하고 나타냅니다.

Modules

이 어셈블리의 모듈을 포함하는 컬렉션을 가져옵니다.

(다음에서 상속됨 Assembly)
PermissionSet

현재 동적 어셈블리의 권한 부여 집합을 가져옵니다.

PermissionSet

현재 어셈블리의 권한 부여 집합을 가져옵니다.

(다음에서 상속됨 Assembly)
ReflectionOnly

동적 어셈블리가 리플렉션 전용 컨텍스트에 있는지 여부를 나타내는 값을 가져옵니다.

ReflectionOnly

이 어셈블리가 리플렉션 전용 컨텍스트에 로드되었는지를 나타내는 Boolean 값을 가져옵니다.

(다음에서 상속됨 Assembly)
SecurityRuleSet

CLR(공용 언어 런타임)가 이 어셈블리에 대해 적용해야 하는 보안 규칙 집합을 나타내는 값을 가져옵니다.

SecurityRuleSet

CLR(공용 언어 런타임)가 이 어셈블리에 대해 적용해야 하는 보안 규칙 집합을 나타내는 값을 가져옵니다.

(다음에서 상속됨 Assembly)

메서드

AddResourceFile(String, String)

이 어셈블리에 기존 리소스 파일을 추가합니다.

AddResourceFile(String, String, ResourceAttributes)

이 어셈블리에 기존 리소스 파일을 추가합니다.

CreateInstance(String)

대/소문자 구분 검색 기능을 사용하여 이 어셈블리에서 지정된 형식을 찾은 다음 시스템 활성기를 사용하여 해당 형식의 인스턴스를 만듭니다.

(다음에서 상속됨 Assembly)
CreateInstance(String, Boolean)

대/소문자 구분 검색 기능을 선택적으로 사용하여, 지정된 형식을 이 어셈블리에서 찾은 다음 시스템 활성기를 사용하여 해당 인스턴스를 만듭니다.

(다음에서 상속됨 Assembly)
CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])

대/소문자 구분 검색 기능을 선택적으로 사용하고 지정된 문화권, 인수, 바인딩 및 활성화 특성을 사용하여, 지정된 형식을 이 어셈블리에서 찾은 다음 시스템 활성기를 사용하여 해당 인스턴스를 만듭니다.

(다음에서 상속됨 Assembly)
DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess)

지정된 이름 및 액세스 권한을 가진 동적 어셈블리를 정의합니다.

DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)

지정된 이름, 액세스 권한 및 특성을 가진 새 어셈블리를 정의합니다.

DefineDynamicModule(String)

이 어셈블리에서 명명된 임시 동적 모듈을 정의합니다.

DefineDynamicModule(String, Boolean)

이 어셈블리에서 명명된 임시 동적 모듈을 정의하고 기호 정보를 내보내야 하는지 여부를 지정합니다.

DefineDynamicModule(String, String)

지정된 파일에 저장될 지정된 이름의 유지할 수 있는 동적 모듈을 정의합니다. 기호 정보를 내보내지 않았습니다.

DefineDynamicModule(String, String, Boolean)

지속 가능한 동적 모듈을 정의하고 모듈 이름, 모듈이 저장될 파일의 이름, 기본 기호 작성기를 사용하여 기호 정보를 내보낼지 여부를 지정합니다.

DefineDynamicModuleCore(String)

파생 클래스에서 재정의되는 경우 이 어셈블리에서 동적 모듈을 정의합니다.

DefinePersistedAssembly(AssemblyName, Assembly, IEnumerable<CustomAttributeBuilder>)

동적 어셈블리를 정의하고 나타냅니다.

DefineResource(String, String, String)

기본 공용 리소스 특성을 사용하여 이 어셈블리에 대한 독립 실행형 관리 리소스를 정의합니다.

DefineResource(String, String, String, ResourceAttributes)

이 어셈블리에 대한 독립 실행형 관리되는 리소스를 정의합니다. 관리되는 리소스에 대해 특성을 지정할 수 있습니다.

DefineUnmanagedResource(Byte[])

이 어셈블리에 대한 관리되는 리소스를 불투명 blob 바이트로 정의합니다.

DefineUnmanagedResource(String)

리소스 파일의 이름이 지정된 이 어셈블리에 대해 관리되지 않는 리소스 파일을 정의합니다.

DefineVersionInfoResource()

어셈블리의 AssemblyName 개체와 어셈블리의 사용자 지정 특성에 지정된 정보를 사용하여 관리되지 않는 버전 정보 리소스를 정의합니다.

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

지정된 사양을 사용하여 이 어셈블리에 대한 관리되지 않은 버전 정보 리소스를 정의합니다.

Equals(Object)

이 인스턴스가 지정한 개체와 같은지 여부를 나타내는 값을 반환합니다.

Equals(Object)

이 어셈블리와 지정된 개체가 서로 같은지 확인합니다.

(다음에서 상속됨 Assembly)
GetCustomAttributes(Boolean)

현재 AssemblyBuilder에 적용된 사용자 지정 특성을 모두 반환합니다.

GetCustomAttributes(Boolean)

이 어셈블리에 대한 사용자 지정 특성을 모두 가져옵니다.

(다음에서 상속됨 Assembly)
GetCustomAttributes(Type, Boolean)

현재 AssemblyBuilder에 적용되었으며 지정된 특성 형식에서 파생되는 사용자 지정 특성을 모두 반환합니다.

GetCustomAttributes(Type, Boolean)

형식에 의해 지정된 대로, 이 어셈블리에 대한 사용자 지정 특성을 가져옵니다.

(다음에서 상속됨 Assembly)
GetCustomAttributesData()

현재 CustomAttributeData에 적용된 특성에 대한 정보가 들어 있는 AssemblyBuilder 개체를 반환합니다.

GetCustomAttributesData()

Assembly 개체로 표현되는, 현재 CustomAttributeData에 적용된 특성 관련 정보를 반환합니다.

(다음에서 상속됨 Assembly)
GetDynamicModule(String)

지정된 이름의 동적 모듈을 반환합니다.

GetDynamicModuleCore(String)

파생 클래스에서 재정의된 경우 지정된 이름의 동적 모듈을 반환합니다.

GetExportedTypes()

이 어셈블리에 정의된 내보낸 형식을 가져옵니다.

GetExportedTypes()

이 어셈블리에 정의된 형식 중 어셈블리 외부에서 볼 수 있는 public 형식을 가져옵니다.

(다음에서 상속됨 Assembly)
GetFile(String)

이 어셈블리의 매니페스트 파일 테이블에서 지정된 파일에 대한 FileStream을 가져옵니다.

GetFile(String)

이 어셈블리의 매니페스트 파일 테이블에서 지정된 파일에 대한 FileStream을 가져옵니다.

(다음에서 상속됨 Assembly)
GetFiles()

어셈블리 매니페스트의 파일 테이블에 있는 파일을 가져옵니다.

(다음에서 상속됨 Assembly)
GetFiles(Boolean)

리소스 모듈의 포함 여부를 지정하여 어셈블리 매니페스트의 파일 테이블에서 파일을 가져옵니다.

GetFiles(Boolean)

리소스 모듈의 포함 여부를 지정하여 어셈블리 매니페스트의 파일 테이블에서 파일을 가져옵니다.

(다음에서 상속됨 Assembly)
GetForwardedTypes()

동적 어셈블리를 정의하고 나타냅니다.

(다음에서 상속됨 Assembly)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Assembly)
GetLoadedModules()

이 어셈블리의 일부인 로드된 모듈을 모두 가져옵니다.

(다음에서 상속됨 Assembly)
GetLoadedModules(Boolean)

이 어셈블리의 일부인 로드된 모듈을 모두 반환하며 선택적으로 리소스 모듈을 포함합니다.

GetLoadedModules(Boolean)

이 어셈블리의 일부인 로드된 모듈을 모두 가져오며 리소스 모듈의 포함 여부를 지정합니다.

(다음에서 상속됨 Assembly)
GetManifestResourceInfo(String)

지정된 리소스가 지속되는 방법에 대한 정보를 반환합니다.

GetManifestResourceNames()

지정된 매니페스트 리소스를 이 어셈블리에서 로드합니다.

GetManifestResourceStream(String)

지정된 매니페스트 리소스를 이 어셈블리에서 로드합니다.

GetManifestResourceStream(Type, String)

지정된 형식의 네임스페이스에 의해 범위가 지정된 매니페스트 리소스를 이 어셈블리에서 로드합니다.

GetManifestResourceStream(Type, String)

지정된 형식의 네임스페이스에 의해 범위가 지정된 매니페스트 리소스를 이 어셈블리에서 로드합니다.

(다음에서 상속됨 Assembly)
GetModule(String)

이 어셈블리에 있는 지정된 모듈을 가져옵니다.

GetModule(String)

이 어셈블리에 있는 지정된 모듈을 가져옵니다.

(다음에서 상속됨 Assembly)
GetModules()

이 어셈블리의 일부인 모듈을 모두 가져옵니다.

(다음에서 상속됨 Assembly)
GetModules(Boolean)

이 어셈블리의 일부인 모듈을 모두 가져오며 선택적으로 리소스 모듈을 포함합니다.

GetModules(Boolean)

이 어셈블리의 일부인 모듈을 모두 가져오며 리소스 모듈의 포함 여부를 지정합니다.

(다음에서 상속됨 Assembly)
GetName()

이 어셈블리에 대한 AssemblyName을 가져옵니다.

(다음에서 상속됨 Assembly)
GetName(Boolean)

현재 동적 어셈블리를 만들 때 지정된 AssemblyName을 가져오고 코드베이스를 지정된 상태로 설정합니다.

GetName(Boolean)

이 어셈블리에 대한 AssemblyName을 가져오며 copiedName에 의해 지정된 대로 코드베이스를 설정합니다.

(다음에서 상속됨 Assembly)
GetObjectData(SerializationInfo, StreamingContext)
사용되지 않음.

이 어셈블리를 다시 인스턴스화하는 데 필요한 데이터가 모두 포함된 serialization 정보를 가져옵니다.

(다음에서 상속됨 Assembly)
GetReferencedAssemblies()

AssemblyName가 참조하는 어셈블리에 대한 AssemblyBuilder 개체의 불완전 목록을 가져옵니다.

GetReferencedAssemblies()

이 어셈블리가 참조하는 모든 어셈블리에 대한 AssemblyName 개체를 가져옵니다.

(다음에서 상속됨 Assembly)
GetSatelliteAssembly(CultureInfo)

지정된 문화권에 대한 위성 어셈블리를 가져옵니다.

GetSatelliteAssembly(CultureInfo)

지정된 문화권에 대한 위성 어셈블리를 가져옵니다.

(다음에서 상속됨 Assembly)
GetSatelliteAssembly(CultureInfo, Version)

지정된 문화권에 대한 지정된 버전의 위성 어셈블리를 가져옵니다.

GetSatelliteAssembly(CultureInfo, Version)

지정된 문화권에 대한 지정된 버전의 위성 어셈블리를 가져옵니다.

(다음에서 상속됨 Assembly)
GetType()

동적 어셈블리를 정의하고 나타냅니다.

(다음에서 상속됨 Assembly)
GetType(String)

어셈블리 인스턴스에서 지정된 이름을 가진 Type 개체를 가져옵니다.

(다음에서 상속됨 Assembly)
GetType(String, Boolean)

어셈블리 인스턴스에서 지정된 이름을 가진 Type 개체를 가져오고, 형식을 찾을 수 없는 경우 선택적으로 예외를 throw합니다.

(다음에서 상속됨 Assembly)
GetType(String, Boolean, Boolean)

현재 AssemblyBuilder에 정의하고 만든 형식에서 지정된 형식을 가져옵니다.

GetType(String, Boolean, Boolean)

대/소문자를 무시할지 여부와 형식이 없으면 예외를 throw할지를 선택적으로 지정하여 어셈블리 인스턴스에서 지정된 이름을 가진 Type 개체를 가져옵니다.

(다음에서 상속됨 Assembly)
GetTypes()

이 어셈블리에 정의된 모든 형식을 가져옵니다.

(다음에서 상속됨 Assembly)
IsDefined(Type, Boolean)

이 멤버에 지정된 특성 형식의 인스턴스가 하나 이상 적용되었는지 여부를 나타내는 값을 반환합니다.

IsDefined(Type, Boolean)

지정된 특성이 어셈블리에 적용되었는지를 나타냅니다.

(다음에서 상속됨 Assembly)
LoadModule(String, Byte[])

내보낸 모듈인 리소스 파일이 포함된 COFF(Common Object File Format) 기반 이미지가 포함된 이 어셈블리의 내부 모듈을 로드합니다.

(다음에서 상속됨 Assembly)
LoadModule(String, Byte[], Byte[])

내보낸 모듈인 리소스 파일이 포함된 COFF(Common Object File Format) 기반 이미지가 포함된 이 어셈블리의 내부 모듈을 로드합니다. 모듈의 기호를 나타내는 원시 바이트도 로드됩니다.

(다음에서 상속됨 Assembly)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Save(Stream)

동적 어셈블리를 정의하고 나타냅니다.

Save(String)

이 동적 어셈블리를 디스크에 저장합니다.

Save(String, PortableExecutableKinds, ImageFileMachine)

이 동적 어셈블리를 디스크에 저장하고, 어셈블리의 실행 파일 및 대상 플랫폼에 코드의 특성을 지정합니다.

SaveCore(Stream)

동적 어셈블리를 정의하고 나타냅니다.

SetCustomAttribute(ConstructorInfo, Byte[])

지정한 사용자 지정 특성 blob을 사용하여 이 어셈블리에 대한 사용자 지정 특성을 설정합니다.

SetCustomAttribute(CustomAttributeBuilder)

사용자 지정 특성 작성기를 사용하여 이 어셈블리에 대한 사용자 지정 특성을 설정합니다.

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

파생 클래스에서 재정의되는 경우 이 어셈블리에서 사용자 지정 특성을 설정합니다.

SetEntryPoint(MethodInfo)

콘솔 애플리케이션이 작성되고 있다고 가정하고 이 동적 어셈블리에 대한 진입점을 설정합니다.

SetEntryPoint(MethodInfo, PEFileKinds)

이 어셈블리에 대한 진입점을 설정하고 빌드되는 이식 가능(PE) 파일의 형식을 정의합니다.

ToString()

표시 이름이라고도 하는 어셈블리의 전체 이름을 반환합니다.

(다음에서 상속됨 Assembly)

이벤트

ModuleResolve

공용 언어 런타임 클래스 로더가 일반적인 방법으로 어셈블리의 내부 모듈에 대한 참조를 확인할 수 없는 경우에 발생합니다.

(다음에서 상속됨 Assembly)

명시적 인터페이스 구현

_Assembly.GetType()

현재 인스턴스의 형식을 반환합니다.

(다음에서 상속됨 Assembly)
_AssemblyBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

_AssemblyBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

_AssemblyBuilder.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

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

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

ICustomAttributeProvider.GetCustomAttributes(Boolean)

명명된 특성을 제외하고 이 멤버에 정의된 모든 사용자 지정 특성의 배열을 반환하거나 사용자 지정 특성이 없는 경우 빈 배열을 반환합니다.

(다음에서 상속됨 Assembly)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

형식으로 식별되는 이 멤버에 정의된 사용자 지정 특성의 배열을 반환하거나 해당 형식의 사용자 지정 특성이 없는 경우 빈 배열을 반환합니다.

(다음에서 상속됨 Assembly)
ICustomAttributeProvider.IsDefined(Type, Boolean)

하나 이상의 attributeType 인스턴스가 이 멤버에 대해 정의되는지 여부를 나타냅니다.

(다음에서 상속됨 Assembly)

확장 메서드

GetExportedTypes(Assembly)

동적 어셈블리를 정의하고 나타냅니다.

GetModules(Assembly)

동적 어셈블리를 정의하고 나타냅니다.

GetTypes(Assembly)

동적 어셈블리를 정의하고 나타냅니다.

GetCustomAttribute(Assembly, Type)

지정된 어셈블리에 적용된 지정된 형식의 사용자 지정 특성을 검색합니다.

GetCustomAttribute<T>(Assembly)

지정된 어셈블리에 적용된 지정된 형식의 사용자 지정 특성을 검색합니다.

GetCustomAttributes(Assembly)

지정된 어셈블리에 적용된 사용자 지정 특성 컬렉션을 검색합니다.

GetCustomAttributes(Assembly, Type)

지정된 어셈블리에 적용된 지정된 형식의 사용자 지정 특성 컬렉션을 검색합니다.

GetCustomAttributes<T>(Assembly)

지정된 어셈블리에 적용된 지정된 형식의 사용자 지정 특성 컬렉션을 검색합니다.

IsDefined(Assembly, Type)

지정된 형식의 사용자 지정 특성이 지정된 어셈블리에 적용되었는지 여부를 나타냅니다.

TryGetRawMetadata(Assembly, Byte*, Int32)

에 사용할 어셈블리의 메타데이터 섹션을 검색합니다 MetadataReader.

적용 대상

추가 정보