AssemblyBuilder Sınıf

Tanım

Dinamik bir derlemeyi tanımlar ve temsil eder.

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
Devralma
AssemblyBuilder
Öznitelikler
Uygulamalar

Örnekler

Aşağıdaki kod örneğinde dinamik derleme tanımlama ve kullanma adımları gösterilmektedir. Örnek derleme, MyDynamicTypebir özel alanı, özel alanı alan ve ayarlayan bir özelliği, özel alanı başlatan oluşturucuları ve kullanıcı tarafından sağlanan bir sayıyı özel alan değeriyle çarparak sonucu döndüren bir yöntemi içeren bir tür içerir.

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

Açıklamalar

Bu API hakkında daha fazla bilgi için bkz. AssemblyBuilder için ek API açıklamaları.

Oluşturucular

AssemblyBuilder()

AssemblyBuilder sınıfının yeni bir örneğini başlatır.

Özellikler

CodeBase
Geçersiz.

Derlemenin konumunu özgün olarak belirtildiği gibi (örneğin, bir AssemblyName nesnede) alır.

CodeBase
Geçersiz.
Geçersiz.

Derlemenin konumunu, örneğin bir AssemblyName nesnede başlangıçta belirtildiği şekilde alır.

(Devralındığı yer: Assembly)
CustomAttributes

Bu derlemenin özel özniteliklerini içeren bir koleksiyonu alır.

(Devralındığı yer: Assembly)
DefinedTypes

Dinamik bir derlemeyi tanımlar ve temsil eder.

DefinedTypes

Bu derlemede tanımlanan türlerin bir koleksiyonunu alır.

(Devralındığı yer: Assembly)
EntryPoint

Bu derlemenin giriş noktasını döndürür.

EntryPoint

Bu derlemenin giriş noktasını alır.

(Devralındığı yer: Assembly)
EscapedCodeBase
Geçersiz.
Geçersiz.

Kod tabanını temsil eden kaçış karakterleri de dahil olmak üzere URI'yi alır.

(Devralındığı yer: Assembly)
Evidence

Bu derlemenin kanıtını alır.

Evidence

Bu derlemenin kanıtını alır.

(Devralındığı yer: Assembly)
ExportedTypes

Bu derlemede tanımlanan ve derlemenin dışında görünen ortak türlerin bir koleksiyonunu alır.

(Devralındığı yer: Assembly)
FullName

Geçerli dinamik derlemenin görünen adını alır.

FullName

Derlemenin görünen adını alır.

(Devralındığı yer: Assembly)
GlobalAssemblyCache
Geçersiz.

Derlemenin genel derleme önbelleğinden yüklenip yüklenmediğini belirten bir değer alır.

GlobalAssemblyCache
Geçersiz.

Derlemenin genel derleme önbelleğinden yüklenip yüklenmediğini belirten bir değer alır (yalnızca .NET Framework).

(Devralındığı yer: Assembly)
HostContext

Dinamik derlemenin oluşturulduğu konak bağlamını alır.

HostContext

Derlemenin yüklendiği konak bağlamını alır.

(Devralındığı yer: Assembly)
ImageRuntimeVersion

Bildirimi içeren dosyaya kaydedilecek ortak dil çalışma zamanının sürümünü alır.

ImageRuntimeVersion

Bildirimi içeren dosyaya kaydedilen ortak dil çalışma zamanının (CLR) sürümünü temsil eden bir dize alır.

(Devralındığı yer: Assembly)
IsCollectible

Bu dinamik derlemenin bir collectible AssemblyLoadContextiçinde tutulup tutulmadığını belirten bir değer alır.

IsCollectible

Bu derlemenin bir collectible AssemblyLoadContextiçinde tutulup tutulmadığını belirten bir değer alır.

(Devralındığı yer: Assembly)
IsDynamic

Geçerli derlemenin dinamik bir derleme olduğunu belirten bir değer alır.

IsDynamic

Geçerli derlemenin yansıma yayma kullanılarak geçerli işlemde dinamik olarak oluşturulup oluşturulmadığını gösteren bir değer alır.

(Devralındığı yer: Assembly)
IsFullyTrusted

Geçerli derlemenin tam güven ile yüklenip yüklenmediğini belirten bir değer alır.

(Devralındığı yer: Assembly)
Location

Gölge kopyalanmadıysa bildirimi içeren yüklenen dosyanın konumunu kod tabanı biçiminde alır.

Location

Bildirimi içeren yüklenen dosyanın tam yolunu veya UNC konumunu alır.

(Devralındığı yer: Assembly)
ManifestModule

Derleme bildirimini içeren geçerli AssemblyBuilder modülü alır.

ManifestModule

Geçerli derlemenin bildirimini içeren modülü alır.

(Devralındığı yer: Assembly)
Modules

Dinamik bir derlemeyi tanımlar ve temsil eder.

Modules

Bu derlemedeki modülleri içeren bir koleksiyon alır.

(Devralındığı yer: Assembly)
PermissionSet

Geçerli dinamik derlemenin izin kümesini alır.

PermissionSet

Geçerli derlemenin izin kümesini alır.

(Devralındığı yer: Assembly)
ReflectionOnly

Dinamik derlemenin yalnızca yansıma bağlamında olup olmadığını belirten bir değer alır.

ReflectionOnly

Bu derlemenin yalnızca yansıma bağlamı içine yüklenip yüklenmediğini belirten bir Boolean değer alır.

(Devralındığı yer: Assembly)
SecurityRuleSet

Ortak dil çalışma zamanının (CLR) bu derleme için hangi güvenlik kuralları kümesini zorunlu kıldığını gösteren bir değer alır.

SecurityRuleSet

Ortak dil çalışma zamanının (CLR) bu derleme için hangi güvenlik kuralları kümesini zorunlu kıldığını gösteren bir değer alır.

(Devralındığı yer: Assembly)

Yöntemler

AddResourceFile(String, String)

Var olan bir kaynak dosyasını bu derlemeye ekler.

AddResourceFile(String, String, ResourceAttributes)

Var olan bir kaynak dosyasını bu derlemeye ekler.

CreateInstance(String)

Belirtilen türü bu derlemeden bulur ve büyük/küçük harfe duyarlı arama kullanarak sistem etkinleştiricisini kullanarak bir örneğini oluşturur.

(Devralındığı yer: Assembly)
CreateInstance(String, Boolean)

Belirtilen türü bu derlemeden bulur ve isteğe bağlı büyük/küçük harfe duyarlı arama ile sistem etkinleştiricisini kullanarak bir örneğini oluşturur.

(Devralındığı yer: Assembly)
CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])

Bu derlemeden belirtilen türü bulur ve isteğe bağlı büyük/küçük harfe duyarlı arama ve belirtilen kültüre, bağımsız değişkenlere ve bağlama ve etkinleştirme özniteliklerine sahip olan sistem etkinleştiricisini kullanarak bir örneği oluşturur.

(Devralındığı yer: Assembly)
DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess)

Belirtilen ada ve erişim haklarına sahip dinamik bir derleme tanımlar.

DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)

Belirtilen ada, erişim haklarına ve özniteliklere sahip yeni bir derleme tanımlar.

DefineDynamicModule(String)

Bu derlemede adlandırılmış bir geçici dinamik modül tanımlar.

DefineDynamicModule(String, Boolean)

Bu derlemede adlandırılmış bir geçici dinamik modül tanımlar ve sembol bilgilerinin yayılıp yayılmayacağını belirtir.

DefineDynamicModule(String, String)

Belirtilen dosyaya kaydedilecek belirtilen ada sahip kalıcı bir dinamik modül tanımlar. Hiçbir sembol bilgisi belirtilmez.

DefineDynamicModule(String, String, Boolean)

Kalıcı bir dinamik modül tanımlar; modül adını, modülün kaydedileceği dosyanın adını ve simge bilgilerinin varsayılan simge yazıcı kullanılarak yayılıp yayılmayacağını belirtir.

DefineDynamicModuleCore(String)

Türetilmiş bir sınıfta geçersiz kılındığında, bu derlemede dinamik bir modül tanımlar.

DefinePersistedAssembly(AssemblyName, Assembly, IEnumerable<CustomAttributeBuilder>)

Dinamik bir derlemeyi tanımlar ve temsil eder.

DefineResource(String, String, String)

Varsayılan genel kaynak özniteliğiyle bu derleme için tek başına yönetilen bir kaynak tanımlar.

DefineResource(String, String, String, ResourceAttributes)

Bu derleme için tek başına yönetilen bir kaynak tanımlar. Yönetilen kaynak için öznitelikler belirtilebilir.

DefineUnmanagedResource(Byte[])

Bu derleme için yönetilmeyen bir kaynağı baytlardan oluşan opak bir blob olarak tanımlar.

DefineUnmanagedResource(String)

Kaynak dosyasının adı verilen bu derleme için yönetilmeyen bir kaynak dosyası tanımlar.

DefineVersionInfoResource()

Derlemenin AssemblyName nesnesinde ve derlemenin özel özniteliklerinde belirtilen bilgileri kullanarak yönetilmeyen bir sürüm bilgisi kaynağı tanımlar.

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

Bu derleme için belirli belirtimlerle yönetilmeyen bir sürüm bilgisi kaynağı tanımlar.

Equals(Object)

Bu örneğin belirtilen nesneye eşit olup olmadığını gösteren bir değer döndürür.

Equals(Object)

Bu derlemenin ve belirtilen nesnenin eşit olup olmadığını belirler.

(Devralındığı yer: Assembly)
GetCustomAttributes(Boolean)

Geçerli AssemblyBuilderöğesine uygulanmış olan tüm özel öznitelikleri döndürür.

GetCustomAttributes(Boolean)

Bu derleme için tüm özel öznitelikleri alır.

(Devralındığı yer: Assembly)
GetCustomAttributes(Type, Boolean)

Geçerli AssemblyBuilderöğesine uygulanmış olan ve belirtilen öznitelik türünden türetilen tüm özel öznitelikleri döndürür.

GetCustomAttributes(Type, Boolean)

Türe göre belirtilen şekilde bu derlemenin özel özniteliklerini alır.

(Devralındığı yer: Assembly)
GetCustomAttributesData()

Geçerli AssemblyBuilderöğesine uygulanmış öznitelikler hakkında bilgi içeren nesneleri döndürürCustomAttributeData.

GetCustomAttributesData()

Nesne olarak CustomAttributeData ifade edilen geçerli Assemblyöğesine uygulanmış öznitelikler hakkındaki bilgileri döndürür.

(Devralındığı yer: Assembly)
GetDynamicModule(String)

Belirtilen ada sahip dinamik modülü döndürür.

GetDynamicModuleCore(String)

Türetilmiş bir sınıfta geçersiz kılındığında, belirtilen ada sahip dinamik modülü döndürür.

GetExportedTypes()

Bu derlemede tanımlanan dışarı aktarılan türleri alır.

GetExportedTypes()

Bu derlemede tanımlanan ve derlemenin dışında görünen ortak türleri alır.

(Devralındığı yer: Assembly)
GetFile(String)

Bu derleme bildiriminin dosya tablosunda belirtilen dosya için bir FileStream alır.

GetFile(String)

Bu derlemenin bildiriminin dosya tablosunda belirtilen dosya için bir FileStream alır.

(Devralındığı yer: Assembly)
GetFiles()

Derleme bildiriminin dosya tablosundaki dosyaları alır.

(Devralındığı yer: Assembly)
GetFiles(Boolean)

Bir derleme bildiriminin dosya tablosundaki dosyaları alır ve kaynak modüllerinin dahil edilip edilmeyeceğini belirtir.

GetFiles(Boolean)

Bir derleme bildiriminin dosya tablosundaki dosyaları alır ve kaynak modüllerinin dahil edilip edilmeyeceğini belirtir.

(Devralındığı yer: Assembly)
GetForwardedTypes()

Dinamik bir derlemeyi tanımlar ve temsil eder.

(Devralındığı yer: Assembly)
GetHashCode()

Bu örneğe ilişkin karma kodu döndürür.

GetHashCode()

Bu örneğe ilişkin karma kodu döndürür.

(Devralındığı yer: Assembly)
GetLoadedModules()

Bu derlemenin parçası olan tüm yüklenen modülleri alır.

(Devralındığı yer: Assembly)
GetLoadedModules(Boolean)

Bu derlemenin parçası olan ve isteğe bağlı olarak kaynak modülleri içeren tüm yüklenen modülleri döndürür.

GetLoadedModules(Boolean)

Kaynak modüllerinin dahil edilip edilmeyeceğini belirterek bu derlemenin parçası olan tüm yüklü modülleri alır.

(Devralındığı yer: Assembly)
GetManifestResourceInfo(String)

Verilen kaynağın nasıl kalıcı hale getirildiği hakkında bilgi döndürür.

GetManifestResourceNames()

Belirtilen bildirim kaynağını bu derlemeden yükler.

GetManifestResourceStream(String)

Belirtilen bildirim kaynağını bu derlemeden yükler.

GetManifestResourceStream(Type, String)

Bu derlemeden belirtilen türün ad alanı tarafından kapsamı belirlenmiş belirtilen bildirim kaynağını yükler.

GetManifestResourceStream(Type, String)

Bu derlemeden belirtilen türün ad alanı tarafından kapsamı belirlenmiş belirtilen bildirim kaynağını yükler.

(Devralındığı yer: Assembly)
GetModule(String)

Bu derlemede belirtilen modülü alır.

GetModule(String)

Bu derlemede belirtilen modülü alır.

(Devralındığı yer: Assembly)
GetModules()

Bu derlemenin parçası olan tüm modülleri alır.

(Devralındığı yer: Assembly)
GetModules(Boolean)

Bu derlemenin parçası olan tüm modülleri alır ve isteğe bağlı olarak kaynak modüllerini içerir.

GetModules(Boolean)

Kaynak modüllerinin dahil edilip edilmeyeceğini belirterek bu derlemenin parçası olan tüm modülleri alır.

(Devralındığı yer: Assembly)
GetName()

Bu derleme için bir AssemblyName alır.

(Devralındığı yer: Assembly)
GetName(Boolean)

AssemblyName Geçerli dinamik derleme oluşturulduğunda belirtilen değerini alır ve kod tabanını belirtilen şekilde ayarlar.

GetName(Boolean)

Kod tabanını tarafından copiedNamebelirtilen şekilde ayarlayarak bu derleme için bir AssemblyName alır.

(Devralındığı yer: Assembly)
GetObjectData(SerializationInfo, StreamingContext)
Geçersiz.

Bu derlemeyi yeniden doğrulamak için gereken tüm verilerle serileştirme bilgilerini alır.

(Devralındığı yer: Assembly)
GetReferencedAssemblies()

Bu AssemblyBuildertarafından başvurulan derlemeler için tamamlanmamış bir nesne listesi AssemblyName alır.

GetReferencedAssemblies()

AssemblyName Bu derleme tarafından başvuruda bulunılan tüm derlemeler için nesneleri alır.

(Devralındığı yer: Assembly)
GetSatelliteAssembly(CultureInfo)

Belirtilen kültür için uydu derlemesini alır.

GetSatelliteAssembly(CultureInfo)

Belirtilen kültür için uydu derlemesini alır.

(Devralındığı yer: Assembly)
GetSatelliteAssembly(CultureInfo, Version)

Belirtilen kültür için uydu derlemesinin belirtilen sürümünü alır.

GetSatelliteAssembly(CultureInfo, Version)

Belirtilen kültür için uydu derlemesinin belirtilen sürümünü alır.

(Devralındığı yer: Assembly)
GetType()

Dinamik bir derlemeyi tanımlar ve temsil eder.

(Devralındığı yer: Assembly)
GetType(String)

Type Derleme örneğinde belirtilen ada sahip nesneyi alır.

(Devralındığı yer: Assembly)
GetType(String, Boolean)

Type Derleme örneğinde belirtilen ada sahip nesneyi alır ve tür bulunamazsa isteğe bağlı olarak bir özel durum oluşturur.

(Devralındığı yer: Assembly)
GetType(String, Boolean, Boolean)

Geçerli AssemblyBuilderiçinde tanımlanan ve oluşturulan türlerden belirtilen türü alır.

GetType(String, Boolean, Boolean)

Type Büyük/küçük harf yoksayma ve tür bulunamazsa özel durum oluşturma seçenekleriyle derleme örneğinde belirtilen ada sahip nesneyi alır.

(Devralındığı yer: Assembly)
GetTypes()

Bu derlemede tanımlanan tüm türleri alır.

(Devralındığı yer: Assembly)
IsDefined(Type, Boolean)

Belirtilen öznitelik türünün bir veya daha fazla örneğinin bu üyeye uygulanıp uygulanmadığını gösteren bir değer döndürür.

IsDefined(Type, Boolean)

Belirtilen özniteliğin derlemeye uygulanıp uygulanmadığını gösterir.

(Devralındığı yer: Assembly)
LoadModule(String, Byte[])

Bu derlemenin içindeki modülü, yayılan bir modülü veya kaynak dosyasını içeren ortak nesne dosyası biçimi (COFF) tabanlı bir görüntüyle yükler.

(Devralındığı yer: Assembly)
LoadModule(String, Byte[], Byte[])

Bu derlemenin içindeki modülü, yayılan bir modülü veya kaynak dosyasını içeren ortak nesne dosyası biçimi (COFF) tabanlı bir görüntüyle yükler. Modülün simgelerini temsil eden ham baytlar da yüklenir.

(Devralındığı yer: Assembly)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
Save(Stream)

Dinamik bir derlemeyi tanımlar ve temsil eder.

Save(String)

Bu dinamik derlemeyi diske kaydeder.

Save(String, PortableExecutableKinds, ImageFileMachine)

Derlemenin yürütülebilir dosyalarında ve hedef platformda kodun doğasını belirterek bu dinamik derlemeyi diske kaydeder.

SaveCore(Stream)

Dinamik bir derlemeyi tanımlar ve temsil eder.

SetCustomAttribute(ConstructorInfo, Byte[])

Belirtilen özel öznitelik blobu kullanarak bu derlemede özel bir öznitelik ayarlayın.

SetCustomAttribute(CustomAttributeBuilder)

Özel öznitelik oluşturucu kullanarak bu derlemede özel bir öznitelik ayarlayın.

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

Türetilmiş bir sınıfta geçersiz kılındığında, bu derlemede özel bir öznitelik ayarlar.

SetEntryPoint(MethodInfo)

Bir konsol uygulamasının oluşturulduğu varsayılarak bu dinamik derleme için giriş noktasını ayarlar.

SetEntryPoint(MethodInfo, PEFileKinds)

Bu derleme için giriş noktasını ayarlar ve derlenen taşınabilir yürütülebilir dosyanın (PE dosyası) türünü tanımlar.

ToString()

Derlemenin görünen adı olarak da bilinen tam adını döndürür.

(Devralındığı yer: Assembly)

Ekinlikler

ModuleResolve

Ortak dil çalışma zamanı sınıf yükleyicisi normal yollarla bir derlemenin iç modülüne başvuruyu çözümleyemediğinde gerçekleşir.

(Devralındığı yer: Assembly)

Belirtik Arabirim Kullanımları

_Assembly.GetType()

Geçerli örneğin türünü döndürür.

(Devralındığı yer: Assembly)
_AssemblyBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

_AssemblyBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir nesne için tür bilgilerini alır ve bu da bir arabirimin tür bilgisini almak için kullanılabilir.

_AssemblyBuilder.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

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

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

ICustomAttributeProvider.GetCustomAttributes(Boolean)

Adlandırılmış öznitelikler hariç, bu üyede tanımlanan tüm özel özniteliklerin dizisini veya özel öznitelikler yoksa boş bir diziyi döndürür.

(Devralındığı yer: Assembly)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

Bu üyede tanımlanan, türe göre tanımlanan bir özel öznitelik dizisi veya bu türde özel öznitelikler yoksa boş bir dizi döndürür.

(Devralındığı yer: Assembly)
ICustomAttributeProvider.IsDefined(Type, Boolean)

Bir veya daha fazla örneğinin bu üyede tanımlanıp tanımlanmadığını attributeType gösterir.

(Devralındığı yer: Assembly)

Uzantı Metotları

GetExportedTypes(Assembly)

Dinamik bir derlemeyi tanımlar ve temsil eder.

GetModules(Assembly)

Dinamik bir derlemeyi tanımlar ve temsil eder.

GetTypes(Assembly)

Dinamik bir derlemeyi tanımlar ve temsil eder.

GetCustomAttribute(Assembly, Type)

Belirtilen bir derlemeye uygulanan belirtilen türde bir özel özniteliği alır.

GetCustomAttribute<T>(Assembly)

Belirtilen bir derlemeye uygulanan belirtilen türde bir özel özniteliği alır.

GetCustomAttributes(Assembly)

Belirtilen derlemeye uygulanan özel özniteliklerden oluşan bir koleksiyonu alır.

GetCustomAttributes(Assembly, Type)

Belirtilen bir derlemeye uygulanan belirtilen türde özel özniteliklerden oluşan bir koleksiyonu alır.

GetCustomAttributes<T>(Assembly)

Belirtilen bir derlemeye uygulanan belirtilen türde özel özniteliklerden oluşan bir koleksiyonu alır.

IsDefined(Assembly, Type)

Belirtilen türlerdeki özel özniteliklerin belirtilen bir derlemeye uygulanıp uygulanmadığını gösterir.

TryGetRawMetadata(Assembly, Byte*, Int32)

ile MetadataReaderkullanmak üzere derlemenin meta veri bölümünü alır.

Şunlara uygulanır

Ayrıca bkz.