Load an object reference onto the stack ???



Hi

I have a class CodeGen in which GenerateILBody is a method that uses
ILGenerator.Emit to create the IL code as method body for a dynamic
method DynMethod. GenerateILBody at runtime must call another method
CallBack of the class CodeGen.

All i have to do is to emit the IL code that loads the object reference
of CodeGen onto the stack, which means I must emit IL in GenerateILBody
to load 'this', which may look like:-

ilgen.Emit(OpCodeToLoad, this);

The this here refers to the CodeGen object reference, and at runtime
will have to use the reference to call the CallBack method.

But there is no overload in ILgenerator.Emit that takes an object
reference.

Please let me know how to load an object reference onto the stack in
IL.

Thanks
Vivek Ragunathan

.



Relevant Pages

  • Load an object reference onto the stack ???
    ... I have a class CodeGen in which GenerateILBody is a method that uses ... All i have to do is to emit the IL code that loads the object reference ... of CodeGen onto the stack, which means I must emit IL in GenerateILBody ... to load 'this', which may look like:- ...
    (microsoft.public.dotnet.languages.csharp)
  • Load an object reference onto the stack ???
    ... I have a class CodeGen in which GenerateILBody is a method that uses ... All i have to do is to emit the IL code that loads the object reference ... of CodeGen onto the stack, which means I must emit IL in GenerateILBody ... to load 'this', which may look like:- ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Load an object reference onto the stack ???
    ... I have a class CodeGen in which GenerateILBody is a method that uses ... All i have to do is to emit the IL code that loads the object reference ... to load 'this', which may look like:- ... constant into the emitted code which then calls GCHandle.FromIntPtr ...
    (microsoft.public.dotnet.framework.clr)
  • Loading a Datagridview taking a long time...sometimes
    ... occassionally tables take a long time to load... ... a single row can take up to 30 seconds to load, ... SqlConnection cnSQL = new SqlConnection; ... I have also had the Error "Object Reference not set to an instance of an ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Load an object reference onto the stack ???
    ... which means I must emit IL in GenerateILBody ... to load 'this', which may look like:- ... ldarg.0 loads 'this' in an instance method. ... Mattias Sjögren mattias @ mvps.org ...
    (microsoft.public.dotnet.framework.clr)