AssemblyBuilder Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Dinamikus szerelvényt definiál és jelöl.
public ref class AssemblyBuilder abstract : System::Reflection::Assembly
public ref class AssemblyBuilder sealed : System::Reflection::Assembly
public ref class AssemblyBuilder sealed : System::Reflection::Assembly, System::Runtime::InteropServices::_AssemblyBuilder
public abstract class AssemblyBuilder : System.Reflection.Assembly
public sealed 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 MustInherit Class AssemblyBuilder
Inherits Assembly
Public NotInheritable Class AssemblyBuilder
Inherits Assembly
Public NotInheritable Class AssemblyBuilder
Inherits Assembly
Implements _AssemblyBuilder
- Öröklődés
- Származtatott
- Attribútumok
- Megvalósítás
Példák
Az alábbi példakód bemutatja, hogyan definiálhat és használhat dinamikus szerelvényt. A példaszerelvény egy típust tartalmaz, MyDynamicTypeamely egy privát mezőt tartalmaz, egy tulajdonságot, amely lekéri és beállítja a magánmezőt, a magánmezőt inicializáló konstruktorokat, valamint egy metódust, amely megszorozza a felhasználó által megadott számot a magánmező értékével, és visszaadja az eredményt.
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)
o2 = 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
Megjegyzések
A dinamikus szerelvény olyan szerelvény, amely a Reflection Emit API-k használatával jön létre. A dinamikus szerelvény hivatkozhat egy másik dinamikus vagy statikus szerelvényben definiált típusokra. Segítségével AssemblyBuilder dinamikus szerelvényeket hozhat létre a memóriában, és futtathatja a kódot ugyanazon alkalmazásfuttatás során. .NET 9 bevezette a PersistedAssemblyBuilder típust a reflexió-kibocsátás teljes körűen felügyelt implementációjával, amely lehetővé teszi a szerelvény fájlba mentését. A dinamikus szerelvény csak egy dinamikus modulból állhat.
Futtatható dinamikus szerelvények a .NET-ben
Futtatható AssemblyBuilder objektum lekéréséhez használja a AssemblyBuilder.DefineDynamicAssembly metódust. A dinamikus szerelvények az alábbi hozzáférési módok egyikével hozhatók létre:
-
Az egy AssemblyBuilder által képviselt dinamikus szerelvény a kibocsátott kód végrehajtására használható.
AssemblyBuilderAccess.RunAndCollect
Az egy AssemblyBuilder által képviselt dinamikus szerelvény a kibocsátott kód végrehajtására használható, és a szemétgyűjtő automatikusan visszaköveteli.
A hozzáférési módot úgy kell megadni, hogy megadja a metódus hívásának megfelelő AssemblyBuilderAccess értékét a AssemblyBuilder.DefineDynamicAssembly dinamikus szerelvény definiálásakor, és később nem módosítható. A futtatókörnyezet egy dinamikus szerelvény hozzáférési módjával optimalizálja a szerelvény belső ábrázolását.
Az alábbi példa bemutatja, hogyan hozhat létre és futtathat szerelvényt:
public void CreateAndRunAssembly(string assemblyPath)
{
AssemblyBuilder ab = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("MyAssembly"), AssemblyBuilderAccess.Run);
ModuleBuilder mob = ab.DefineDynamicModule("MyModule");
TypeBuilder tb = mob.DefineType("MyType", TypeAttributes.Public | TypeAttributes.Class);
MethodBuilder mb = tb.DefineMethod("SumMethod", MethodAttributes.Public | MethodAttributes.Static,
typeof(int), new Type[] {typeof(int), typeof(int)});
ILGenerator il = mb.GetILGenerator();
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldarg_1);
il.Emit(OpCodes.Add);
il.Emit(OpCodes.Ret);
Type type = tb.CreateType();
MethodInfo method = type.GetMethod("SumMethod");
Console.WriteLine(method.Invoke(null, new object[] { 5, 10 }));
}
A PersistedAssemblyBuilder típus, amelyből származik AssemblyBuilder, lehetővé teszi a dinamikus szerelvények mentését. További információkért tekintse meg a használati forgatókönyveket és példákat a következő helyen PersistedAssemblyBuilder: .
Konstruktorok
| Name | Description |
|---|---|
| AssemblyBuilder() |
Inicializálja a AssemblyBuilder osztály új példányát. |
Tulajdonságok
| Name | Description |
|---|---|
| CodeBase |
Elavult.
Lekéri a szerelvény eredetileg megadott helyét (például egy AssemblyName objektumban). |
| CodeBase |
Elavult.
Elavult.
Lekéri a szerelvény eredetileg megadott helyét, például egy AssemblyName objektumban. (Öröklődés forrása Assembly) |
| CustomAttributes |
Lekéri a szerelvény egyéni attribútumait tartalmazó gyűjteményt. (Öröklődés forrása Assembly) |
| DefinedTypes |
Dinamikus szerelvényt definiál és jelöl. |
| DefinedTypes |
Lekéri a szerelvényben definiált típusok gyűjteményét. (Öröklődés forrása Assembly) |
| EntryPoint |
A szerelvény belépési pontját adja vissza. |
| EntryPoint |
Lekéri a szerelvény belépési pontját. (Öröklődés forrása Assembly) |
| EscapedCodeBase |
Elavult.
Elavult.
Lekéri a kódbázist képviselő URI-t, beleértve a feloldó karaktereket is. (Öröklődés forrása Assembly) |
| Evidence |
Lekéri a bizonyítékokat a gyűlésről. |
| Evidence |
Lekéri a bizonyítékokat a gyűlésről. (Öröklődés forrása Assembly) |
| ExportedTypes |
Lekéri az ebben a szerelvényben definiált nyilvános típusok gyűjteményét, amelyek a szerelvényen kívül láthatók. (Öröklődés forrása Assembly) |
| FullName |
Lekéri az aktuális dinamikus szerelvény megjelenítendő nevét. |
| FullName |
Lekéri a szerelvény megjelenítendő nevét. (Öröklődés forrása Assembly) |
| GlobalAssemblyCache |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a szerelvény betöltődött-e a globális szerelvény-gyorsítótárból. |
| GlobalAssemblyCache |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a szerelvény betöltődött-e a globális szerelvény-gyorsítótárból (csak .NET keretrendszerből). (Öröklődés forrása Assembly) |
| HostContext |
Lekéri azt a gazdagépkörnyezetet, amelyben a dinamikus szerelvény létrejön. |
| HostContext |
Lekéri azt a gazdagépkörnyezetet, amellyel a szerelvény betöltődött. (Öröklődés forrása Assembly) |
| ImageRuntimeVersion |
Lekéri a jegyzékfájlba mentett közös nyelvi futtatókörnyezet verzióját. |
| ImageRuntimeVersion |
Lekéri a jegyzékfájlba mentett közös nyelvi futtatókörnyezet (CLR) verzióját képviselő sztringet. (Öröklődés forrása Assembly) |
| IsCollectible |
Olyan értéket kap, amely jelzi, hogy a dinamikus szerelvény egy gyűjthető helyen van-e tárolva AssemblyLoadContext. |
| IsCollectible |
Olyan értéket kap, amely jelzi, hogy a szerelvény gyűjthető AssemblyLoadContexthelyen van-e. (Öröklődés forrása Assembly) |
| IsDynamic |
Olyan értéket kap, amely azt jelzi, hogy az aktuális szerelvény egy dinamikus szerelvény. |
| IsFullyTrusted |
Olyan értéket kap, amely jelzi, hogy az aktuális szerelvény teljes megbízhatósággal van-e betöltve. (Öröklődés forrása Assembly) |
| Location |
Lekéri a jegyzékfájlt tartalmazó betöltött fájl helyét kódbázis formátumban, ha az nincs árnyékmásolva. |
| Location |
Lekéri a jegyzékfájlt tartalmazó betöltött fájl teljes elérési útját vagy UNC-helyét. (Öröklődés forrása Assembly) |
| ManifestModule |
Lekéri az aktuális AssemblyBuilder modult, amely tartalmazza a szerelvényjegyzéket. |
| ManifestModule |
Lekéri az aktuális szerelvény jegyzékjegyzékét tartalmazó modult. (Öröklődés forrása Assembly) |
| Modules |
Dinamikus szerelvényt definiál és jelöl. |
| Modules |
Lekéri a szerelvény moduljait tartalmazó gyűjteményt. (Öröklődés forrása Assembly) |
| PermissionSet |
Lekéri az aktuális dinamikus szerelvény támogatási készletét. |
| ReflectionOnly |
Lekéri az értéket, amely jelzi, hogy a dinamikus szerelvény csak tükröződési környezetben van-e. |
| ReflectionOnly |
Beolvas egy Boolean értéket, amely jelzi, hogy a szerelvény be lett-e töltve a csak tükrözési környezetbe. (Öröklődés forrása Assembly) |
| SecurityRuleSet |
Olyan értéket kap, amely jelzi, hogy a közös nyelvi futtatókörnyezet (CLR) mely biztonsági szabályokat kényszeríti ki ehhez a szerelvényhez. |
| SecurityRuleSet |
Olyan értéket kap, amely jelzi, hogy a közös nyelvi futtatókörnyezet (CLR) mely biztonsági szabályokat kényszeríti ki ehhez a szerelvényhez. (Öröklődés forrása Assembly) |
Metódusok
| Name | Description |
|---|---|
| AddResourceFile(String, String, ResourceAttributes) |
Hozzáad egy meglévő erőforrásfájlt ehhez a szerelvényhez. |
| AddResourceFile(String, String) |
Hozzáad egy meglévő erőforrásfájlt ehhez a szerelvényhez. |
| CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[]) |
Megkeresi a megadott típust ebből a szerelvényből, és létrehozza annak egy példányát a rendszeraktivátor használatával, a kis- és nagybetűk megkülönböztetésével, valamint a megadott kultúrával, argumentumokkal, kötési és aktiválási attribútumokkal. (Öröklődés forrása Assembly) |
| CreateInstance(String, Boolean) |
Megkeresi a megadott típust ebből a szerelvényből, és létrehozza annak egy példányát a rendszeraktivátor használatával, a kis- és nagybetűket nem kötelező kereséssel. (Öröklődés forrása Assembly) |
| CreateInstance(String) |
Megkeresi a megadott típust ebből a szerelvényből, és létrehoz egy példányt a rendszeraktivátor használatával, a kis- és nagybetűket megkülönböztető kereséssel. (Öröklődés forrása Assembly) |
| DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>) |
A megadott névvel, hozzáférési jogosultságokkal és attribútumokkal rendelkező dinamikus szerelvényt definiál. |
| DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess) |
Dinamikus szerelvényt definiál, amely rendelkezik a megadott névvel és hozzáférési jogosultságokkal. |
| DefineDynamicModule(String, Boolean) |
Definiál egy elnevezett átmeneti dinamikus modult ebben a szerelvényben, és meghatározza, hogy ki kell-e adni a szimbóluminformációkat. |
| DefineDynamicModule(String, String, Boolean) |
Meghatároz egy megőrizhető dinamikus modult, megadva a modul nevét, annak a fájlnak a nevét, amelybe a modult menteni kívánja, valamint azt, hogy a szimbóluminformációkat az alapértelmezett szimbólumíró használatával kell-e kibocsátani. |
| DefineDynamicModule(String, String) |
Meghatároz egy megőrizhető dinamikus modult a megadott fájlba mentendő utónévvel. A rendszer nem ad ki szimbóluminformációt. |
| DefineDynamicModule(String) |
Egy elnevezett átmeneti dinamikus modult határoz meg ebben a szerelvényben. |
| DefineDynamicModuleCore(String) |
Ha egy származtatott osztályban felül van bírálva, egy dinamikus modult határoz meg ebben a szerelvényben. |
| DefineResource(String, String, String, ResourceAttributes) |
Önálló felügyelt erőforrást határoz meg ehhez a szerelvényhez. A felügyelt erőforráshoz attribútumok adhatók meg. |
| DefineResource(String, String, String) |
Egy önálló felügyelt erőforrást határoz meg ehhez a szerelvényhez az alapértelmezett nyilvános erőforrás-attribútummal. |
| DefineUnmanagedResource(Byte[]) |
A szerelvényhez nem felügyelt erőforrást definiál átlátszatlan bájtblobként. |
| DefineUnmanagedResource(String) |
Egy nem felügyelt erőforrásfájlt határoz meg ehhez a szerelvényhez az erőforrásfájl neve alapján. |
| DefineVersionInfoResource() |
Nem felügyelt verzióinformációs erőforrást határoz meg a szerelvény AssemblyName objektumában és a szerelvény egyéni attribútumaiban megadott adatok használatával. |
| DefineVersionInfoResource(String, String, String, String, String) |
Egy nem felügyelt verzióinformációs erőforrást határoz meg ehhez a szerelvényhez a megadott specifikációkkal. |
| Equals(Object) |
Olyan értéket ad vissza, amely jelzi, hogy ez a példány egyenlő-e a megadott objektummal. |
| Equals(Object) |
Meghatározza, hogy ez a szerelvény és a megadott objektum egyenlő-e. (Öröklődés forrása Assembly) |
| GetCustomAttributes(Boolean) |
Az aktuálisra AssemblyBuilderalkalmazott összes egyéni attribútumot adja vissza. |
| GetCustomAttributes(Boolean) |
Lekéri a szerelvény összes egyéni attribútumát. (Öröklődés forrása Assembly) |
| GetCustomAttributes(Type, Boolean) |
Az aktuálisra AssemblyBuilderalkalmazott összes egyéni attribútumot adja vissza, amely egy adott attribútumtípusból származik. |
| GetCustomAttributes(Type, Boolean) |
Lekéri a szerelvény egyéni attribútumait a típus szerint megadott módon. (Öröklődés forrása Assembly) |
| GetCustomAttributesData() |
CustomAttributeData Az aktuálisra AssemblyBuilderalkalmazott attribútumokkal kapcsolatos információkat tartalmazó objektumokat ad vissza. |
| GetCustomAttributesData() |
Az aktuálisra Assemblyalkalmazott attribútumokra vonatkozó információkat adja vissza objektumként CustomAttributeData kifejezve. (Öröklődés forrása Assembly) |
| GetDynamicModule(String) |
A megadott névvel rendelkező dinamikus modult adja vissza. |
| GetDynamicModuleCore(String) |
Ha egy származtatott osztályban felül van bírálva, a megadott névvel adja vissza a dinamikus modult. |
| GetExportedTypes() |
Lekéri a szerelvényben definiált exportált típusokat. |
| GetExportedTypes() |
Lekéri az ebben a szerelvényben definiált nyilvános típusokat, amelyek a szerelvényen kívül láthatók. (Öröklődés forrása Assembly) |
| GetFile(String) |
FileStream Lekéri a megadott fájlt a szerelvény jegyzékfájljának fájltáblájában. |
| GetFile(String) |
FileStream Lekéri a megadott fájlt a szerelvény jegyzékfájljának fájltáblájában. (Öröklődés forrása Assembly) |
| GetFiles() |
Lekéri a fájlokat egy szerelvényjegyzék fájltáblájában. (Öröklődés forrása Assembly) |
| GetFiles(Boolean) |
Lekéri a fájlokat egy szerelvényjegyzék fájltáblájában, megadva, hogy az erőforrásmodulokat is tartalmazza-e. |
| GetFiles(Boolean) |
Lekéri a fájlokat egy szerelvényjegyzék fájltáblájában, megadva, hogy az erőforrásmodulokat is tartalmazza-e. (Öröklődés forrása Assembly) |
| GetForwardedTypes() |
Dinamikus szerelvényt definiál és jelöl. (Öröklődés forrása Assembly) |
| GetHashCode() |
A példány kivonatkódját adja vissza. |
| GetHashCode() |
A példány kivonatkódját adja vissza. (Öröklődés forrása Assembly) |
| GetLoadedModules() |
Lekéri a szerelvény részét képező összes betöltött modult. (Öröklődés forrása Assembly) |
| GetLoadedModules(Boolean) |
A szerelvény részét képező összes betöltött modult visszaadja, és opcionálisan erőforrásmodulokat is tartalmaz. |
| GetLoadedModules(Boolean) |
Lekéri a szerelvény részét képező összes betöltött modult, megadva, hogy az erőforrásmodulokat is belefoglalja-e. (Öröklődés forrása Assembly) |
| GetManifestResourceInfo(String) |
Az adott erőforrás megőrzésének módját adja vissza. |
| GetManifestResourceNames() |
Betölti a megadott jegyzékerőforrást ebből a szerelvényből. |
| GetManifestResourceStream(String) |
Betölti a megadott jegyzékerőforrást ebből a szerelvényből. |
| GetManifestResourceStream(Type, String) |
Betölti a megadott jegyzékerőforrást, amely a megadott típus névtere szerint van meghatározva ebből a szerelvényből. |
| GetManifestResourceStream(Type, String) |
Betölti a megadott jegyzékerőforrást, amely a megadott típus névtere szerint van meghatározva ebből a szerelvényből. (Öröklődés forrása Assembly) |
| GetModule(String) |
Lekéri a megadott modult ebben a szerelvényben. |
| GetModule(String) |
Lekéri a megadott modult ebben a szerelvényben. (Öröklődés forrása Assembly) |
| GetModules() |
Lekéri a szerelvény részét képező összes modult. (Öröklődés forrása Assembly) |
| GetModules(Boolean) |
Lekéri a szerelvény részét képező összes modult, és opcionálisan erőforrásmodulokat is tartalmaz. |
| GetModules(Boolean) |
Lekéri a szerelvény részét képező összes modult, megadva, hogy az erőforrásmodulokat is belefoglalja-e. (Öröklődés forrása Assembly) |
| GetName() |
Kap egy ilyen AssemblyName szerelvényt. (Öröklődés forrása Assembly) |
| GetName(Boolean) |
Lekéri az AssemblyName aktuális dinamikus szerelvény létrehozásakor megadott értéket, és a megadott módon állítja be a kódbázist. |
| GetName(Boolean) |
Lekéri a szerelvényt AssemblyName , és a kódbázist a megadott módon állítja |
| GetObjectData(SerializationInfo, StreamingContext) |
Elavult.
Lekéri a szerializálási adatokat a szerelvény újbóli létrehozásához szükséges összes adattal. (Öröklődés forrása Assembly) |
| GetReferencedAssemblies() |
Lekéri az AssemblyName ebben AssemblyBuildera szakaszban hivatkozott szerelvények objektumainak hiányos listáját. |
| GetReferencedAssemblies() |
Lekéri a AssemblyName szerelvény által hivatkozott összes szerelvény objektumait. (Öröklődés forrása Assembly) |
| GetSatelliteAssembly(CultureInfo, Version) |
Lekéri a műholdas szerelvény megadott verzióját a megadott kultúrához. |
| GetSatelliteAssembly(CultureInfo, Version) |
Lekéri a műholdas szerelvény megadott verzióját a megadott kultúrához. (Öröklődés forrása Assembly) |
| GetSatelliteAssembly(CultureInfo) |
Lekéri a megadott kultúrához tartozó műholdas szerelvényt. |
| GetSatelliteAssembly(CultureInfo) |
Lekéri a megadott kultúrához tartozó műholdas szerelvényt. (Öröklődés forrása Assembly) |
| GetType() |
Dinamikus szerelvényt definiál és jelöl. (Öröklődés forrása Assembly) |
| GetType(String, Boolean, Boolean) |
Lekéri a megadott típust az aktuálisban AssemblyBuilderdefiniált és létrehozott típusok közül. |
| GetType(String, Boolean, Boolean) |
Lekéri az Type objektumot a szerelvénypéldányban megadott névvel, az eset figyelmen kívül hagyásának lehetőségeivel, és kivételt ad, ha a típus nem található. (Öröklődés forrása Assembly) |
| GetType(String, Boolean) |
Lekéri a Type megadott nevű objektumot a szerelvénypéldányban, és opcionálisan kivételt ad, ha a típus nem található. (Öröklődés forrása Assembly) |
| GetType(String) |
Lekéri az Type objektumot a megadott névvel a szerelvénypéldányban. (Öröklődés forrása Assembly) |
| GetTypes() |
Lekéri a szerelvényben definiált összes típust. (Öröklődés forrása Assembly) |
| IsDefined(Type, Boolean) |
Olyan értéket ad vissza, amely jelzi, hogy a megadott attribútumtípus egy vagy több példánya van-e alkalmazva erre a tagra. |
| IsDefined(Type, Boolean) |
Azt jelzi, hogy egy megadott attribútum lett-e alkalmazva a szerelvényre. (Öröklődés forrása Assembly) |
| LoadModule(String, Byte[], Byte[]) |
Betölti a modult a szerelvényen belül egy közös objektumfájl-formátummal (COFF)-alapú képpel, amely egy kibocsátott modult vagy egy erőforrásfájlt tartalmaz. A modul szimbólumait jelképező nyers bájtok is betöltésre kerülnek. (Öröklődés forrása Assembly) |
| LoadModule(String, Byte[]) |
Betölti a modult a szerelvényen belül egy közös objektumfájl-formátummal (COFF)-alapú képpel, amely egy kibocsátott modult vagy egy erőforrásfájlt tartalmaz. (Öröklődés forrása Assembly) |
| MemberwiseClone() |
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| Save(String, PortableExecutableKinds, ImageFileMachine) |
Menti ezt a dinamikus szerelvényt a lemezre, meghatározva a kód jellegét a szerelvény végrehajtható verzióiban és a célplatformon. |
| Save(String) |
A dinamikus szerelvényt lemezre menti. |
| SetCustomAttribute(ConstructorInfo, Byte[]) |
Egyéni attribútum beállítása ezen a szerelvényen egy megadott egyéni attribútumblob használatával. |
| SetCustomAttribute(CustomAttributeBuilder) |
Egyéni attribútum beállítása ezen a szerelvényen egy egyéni attribútumszerkesztővel. |
| SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>) |
Ha felül van bírálva egy származtatott osztályban, beállít egy egyéni attribútumot ezen a szerelvényen. |
| SetEntryPoint(MethodInfo, PEFileKinds) |
Beállítja a szerelvény belépési pontját, és meghatározza a létrehozandó hordozható végrehajtható fájl (PE-fájl) típusát. |
| SetEntryPoint(MethodInfo) |
Beállítja a dinamikus szerelvény belépési pontját, feltéve, hogy egy konzolalkalmazás készül. |
| ToString() |
A szerelvény teljes nevét adja vissza, más néven a megjelenítendő nevet. (Öröklődés forrása Assembly) |
esemény
| Name | Description |
|---|---|
| ModuleResolve |
Akkor fordul elő, ha a közös nyelvi futtatókörnyezeti osztálybetöltő normál módon nem tudja feloldani a szerelvény belső moduljára mutató hivatkozást. (Öröklődés forrása Assembly) |
Explicit interfész-implementációk
| Name | Description |
|---|---|
| _Assembly.GetType() |
Az aktuális példány típusát adja vissza. (Öröklődés forrása Assembly) |
| _AssemblyBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Névkészletet képez le a küldési azonosítók megfelelő készletére. |
| _AssemblyBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) |
Lekéri egy objektum típusadatait, amelyek aztán a felület típusadatainak lekérésére használhatók. |
| _AssemblyBuilder.GetTypeInfoCount(UInt32) |
Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1). |
| _AssemblyBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz. |
| ICustomAttributeProvider.GetCustomAttributes(Boolean) |
A tagon definiált összes egyéni attribútum tömbjének értékét adja vissza, kivéve az elnevezett attribútumokat, vagy üres tömböt, ha nincsenek egyéni attribútumok. (Öröklődés forrása Assembly) |
| ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) |
A tagon definiált egyéni attribútumokat tartalmazó tömböt ad vissza, amely típus szerint van azonosítva, vagy üres tömböt ad vissza, ha nincsenek ilyen típusú egyéni attribútumok. (Öröklődés forrása Assembly) |
| ICustomAttributeProvider.IsDefined(Type, Boolean) |
Azt jelzi, hogy egy vagy több példány |
Bővítő metódusok
| Name | Description |
|---|---|
| GetCustomAttribute(Assembly, Type) |
Lekéri a megadott típusú egyéni attribútumot, amelyet egy adott szerelvényre alkalmaz. |
| GetCustomAttribute<T>(Assembly) |
Lekéri a megadott típusú egyéni attribútumot, amelyet egy adott szerelvényre alkalmaz. |
| GetCustomAttributes(Assembly, Type) |
Egy megadott típusú egyéni attribútumok gyűjteményét kéri le, amelyek egy adott szerelvényre lesznek alkalmazva. |
| GetCustomAttributes(Assembly) |
Egy adott szerelvényre alkalmazott egyéni attribútumok gyűjteményét kéri le. |
| GetCustomAttributes<T>(Assembly) |
Egy megadott típusú egyéni attribútumok gyűjteményét kéri le, amelyek egy adott szerelvényre lesznek alkalmazva. |
| GetExportedTypes(Assembly) |
Dinamikus szerelvényt definiál és jelöl. |
| GetModules(Assembly) |
Dinamikus szerelvényt definiál és jelöl. |
| GetTypes(Assembly) |
Dinamikus szerelvényt definiál és jelöl. |
| IsDefined(Assembly, Type) |
Azt jelzi, hogy a megadott típusú egyéni attribútumok alkalmazhatók-e egy adott szerelvényre. |
| TryGetRawMetadata(Assembly, Byte*, Int32) |
Lekéri a szerelvény metaadatszakaszát a következővel MetadataReadervaló használatra: . |