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 将的地址推送field到堆栈上指定的对象中。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.

ldflda指令将推送到堆栈上的对象中字段的地址。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.

返回的值ldflda是托管的指针 (类型&) 对象推送到堆栈上为非托管指针上,除非在这种情况下返回地址也是的非托管的指针 (类型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).

ldflda指令可以跟一个或两个UnalignedVolatile前缀。The ldflda instruction can be preceded by either or both of the Unaligned and Volatile prefixes.

InvalidOperationException 如果该对象不是在应用程序域正在从中访问它会引发。InvalidOperationException 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.

NullReferenceException 如果对象为空且该字段不是静态。NullReferenceException is thrown if the object is null and the field is not static.

MissingFieldException 如果在元数据中找不到指定的字段将引发。MissingFieldException 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.

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

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

适用于