OpCodes.Ldflda OpCodes.Ldflda OpCodes.Ldflda OpCodes.Ldflda Field

定义

查找对象中其引用当前位于计算堆栈的字段的地址。Finds the address of a field in the object whose reference is currently on the evaluation stack.

public: static initonly System::Reflection::Emit::OpCode Ldflda;
public static readonly System.Reflection.Emit.OpCode Ldflda;
 staticval mutable Ldflda : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldflda As OpCode 

字段值

注解

下表列出了指令的十六进制和 Microsoft 中间语言(MSIL)程序集格式以及简短的参考摘要:The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

格式Format 程序集格式Assembly Format 说明Description
7C < T >7C < T > ldflda fieldldflda field 将指定对象中 @no__t 0 的地址推送到堆栈上。Pushes the address of field in a specified object onto the stack.

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. 对象引用(或指针)被推送到堆栈上。An object reference (or pointer) is pushed onto the stack.

  2. 从堆栈中弹出对象引用(或指针);找到对象中指定字段的地址。The object reference (or pointer) is popped from the stack; the address of the specified field in the object is found.

  3. 指定字段的地址被推送到堆栈上。The address of the specified field is pushed onto the stack.

@No__t-0 指令将位于对象中的字段的地址推送到堆栈上。The ldflda instruction pushes the address of a field located in an object onto the stack. 对象必须位于堆栈上以作为对象引用(类型为 O)、托管指针(类型 &)、非托管指针(类型 native int)、暂时性指针(类型 *)或值类型的实例。The object must be on the stack as an object reference (type O), a managed pointer (type &), an unmanaged pointer (type native int), a transient pointer (type *), or an instance of a value type. 可验证代码中不允许使用非托管指针。The use of an unmanaged pointer is not permitted in verifiable code. 对象的字段由必须引用字段成员的元数据标记指定。The object's field is specified by a metadata token that must refer to a field member.

@No__t 返回的值为托管指针(类型 &),除非将该对象作为非托管指针推送到堆栈上,在这种情况下,返回地址也是非托管指针(类型 native int)。The value returned by ldflda is a managed pointer (type &) unless the object is pushed onto the stack as an unmanaged pointer, in which case the return address is also an unmanaged pointer (type native int).

@No__t-0 指令前面可以是 Unaligned 和/或 @no__t 前缀。The ldflda instruction can be preceded by either or both of the Unaligned and Volatile prefixes.

如果对象不在从中访问它的应用程序域中,则会引发 InvalidOperationExceptionInvalidOperationException is thrown if the object is not within the application domain from which it is being accessed. 不在访问应用程序域中的字段的地址无法加载。The address of a field that is not inside the accessing application domain cannot be loaded.

如果对象为 null,并且该字段不是静态的,则会引发 NullReferenceExceptionNullReferenceException is thrown if the object is null and the field is not static.

如果在元数据中找不到指定的字段,则会引发 MissingFieldExceptionMissingFieldException is thrown if the specified field is not found in the metadata. 当 Microsoft 中间语言(MSIL)指令转换为本机代码而不是在运行时,通常会检查此情况。This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time.

以下 @no__t 0 方法重载可以使用 @no__t 操作码:The following Emit method overload can use the ldflda opcode:

  • ILGenerator (OpCode,FieldInfo)ILGenerator.Emit(OpCode, FieldInfo)

适用于