Is there an easy way to call a method such as Console.Read() using
ILGenerator.Emit? I can't quite understand how to call a method and when I
tried to use a string, the IL code generated was:
Call "void [mscorlib]System.Console.Read( )"
Is there any way by which to remove the quotes surrounding it? How do I
actually initiate a Call properly?
"Ed Dore [MSFT]" - 16 Feb 2005 21:57 GMT
Can you elaborate a bit? I'm not quite sure I understand what you are
looking for.
The ILGenerator.Emit amd ILGenerator.EmitCall functions will emit opcodes
into a dynamically generated assembly, but there isn't really a way (short
of disassembling it) to retrieve the actual IL.
Just a few weeks ago I was looking to see if there was an easy way to use
the Reflection.Emit classes to generate textual IL, but there doesn't
appear to be. I did run across some work done by John Gough (of "Compiling
for the .NET Common Language Runtime (CLR) fame, and Diane Corney
consisting of a C# library that would emit textual IL called PEAPI. But I
cannot locate it outside of the Mono open source project out on
http://www.mono-project.com/using/relnotes/1.0-features.html.
Joel Pobar's CLR weblog has some interesting info on the unmaged metadata
reader/writer API's at
http://blogs.msdn.com/joelpob/archive/2004/09/22.aspx
He's also got an entry on a generating a simple hello world app via
Reflection.Emit at:
http://blogs.msdn.com/joelpob/archive/2004/01/21/61411.aspx
I also ran across this interesting entry in Mike Stall's block on how to go
about debugging dynamically generated code (via Reflection.Emit), that I
thought was pretty interesting too.
http://blogs.msdn.com/jmstall/archive/2005/02/03/366429.aspx
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.