Calling IL instruction from C# code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jean Stax

    #1

    Calling IL instruction from C# code

    Hi !

    I am looking for a way to call IL instruction from withing C# code. I
    am not talking about System.Reflecti on.Emit sort of topics, but rather
    about existing C# code, where I want to call IL instruction.

    More specificly, I want to call "OpCodes.No p" instruction in C# code
    in order to make some label for myself, which I would be able to
    identify while reflecting IL generated code.

    So far, I found InvokeMethod methods in different classes (like
    Type.InvokeMeth od), but they don't seem to meet my needs.

    Any ideas ?

    Thanks
    Jean
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Calling IL instruction from C# code

    Jean,

    I don't understand why you want to call Nop as a label? If you reflect
    on some code, it doesn't show you what op codes were executed, rather, what
    is stored in the assembly. If you call Nop yourself, that won't be shown
    anywhere using reflection.

    What exactly are you trying to do?

    If you want to make your own IL calls, then I think you would have to
    create your own assembly in memory and then execute the methods on the types
    in that assembly.

    Hope this helps.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "Jean Stax" <jean_stax@hotm ail.com> wrote in message
    news:df5c1ee6.0 309120226.30166 1f2@posting.goo gle.com...[color=blue]
    > Hi !
    >
    > I am looking for a way to call IL instruction from withing C# code. I
    > am not talking about System.Reflecti on.Emit sort of topics, but rather
    > about existing C# code, where I want to call IL instruction.
    >
    > More specificly, I want to call "OpCodes.No p" instruction in C# code
    > in order to make some label for myself, which I would be able to
    > identify while reflecting IL generated code.
    >
    > So far, I found InvokeMethod methods in different classes (like
    > Type.InvokeMeth od), but they don't seem to meet my needs.
    >
    > Any ideas ?
    >
    > Thanks
    > Jean[/color]


    Comment

    • Jean Stax

      #3
      Re: Calling IL instruction from C# code

      Hi !

      I wanted to create somthing that analyzes / parses IL code (IL
      instructions, which are resulted from C# compillation). Now I thought
      about the way to find the correspondence between the line in C# code
      and IL code. Of course, one C# line maybe transkated to a couple of IL
      lines (instructions). By "labeling" the C# code, I thought I would be
      able to reach this correpondence.

      Maybe you have some better ideas ?

      Thanks.
      Jean.

      "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote in message news:<ub3bRxSeD HA.3096@TK2MSFT NGP11.phx.gbl>. ..[color=blue]
      > Jean,
      >
      > I don't understand why you want to call Nop as a label? If you reflect
      > on some code, it doesn't show you what op codes were executed, rather, what
      > is stored in the assembly. If you call Nop yourself, that won't be shown
      > anywhere using reflection.
      >
      > What exactly are you trying to do?
      >
      > If you want to make your own IL calls, then I think you would have to
      > create your own assembly in memory and then execute the methods on the types
      > in that assembly.
      >
      > Hope this helps.
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - nicholas.paldin o@exisconsultin g.com
      >
      > "Jean Stax" <jean_stax@hotm ail.com> wrote in message
      > news:df5c1ee6.0 309120226.30166 1f2@posting.goo gle.com...[color=green]
      > > Hi !
      > >
      > > I am looking for a way to call IL instruction from withing C# code. I
      > > am not talking about System.Reflecti on.Emit sort of topics, but rather
      > > about existing C# code, where I want to call IL instruction.
      > >
      > > More specificly, I want to call "OpCodes.No p" instruction in C# code
      > > in order to make some label for myself, which I would be able to
      > > identify while reflecting IL generated code.
      > >
      > > So far, I found InvokeMethod methods in different classes (like
      > > Type.InvokeMeth od), but they don't seem to meet my needs.
      > >
      > > Any ideas ?
      > >
      > > Thanks
      > > Jean[/color][/color]

      Comment

      Working...