473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Getting IL Code for a Method

Hello,

With reflection, is it a way to get (in managed code) the IL Code of a
method ?
I would like to retrieve for a Method, all the called inner Method.

I know how to Emit IL Code in assembly, but I can't find the reverse
possibility.
The only think I have found is the MethodHandle function of MethodInfo
class, that theorically return the metadata, but I can't find a way to go
further.

Thanks.
Nov 17 '05 #1
3 3354
Ludovic,

In .NET 2.0, you will be able to call the GetMethodBody method on the
MethodInfo instance and get a MethodBody instance which will allow you
access to the IL as a byte array.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ludovic DE FREITAS" <Lu**************@discussions.microsoft.com> wrote in
message news:1F**********************************@microsof t.com...
Hello,

With reflection, is it a way to get (in managed code) the IL Code of a
method ?
I would like to retrieve for a Method, all the called inner Method.

I know how to Emit IL Code in assembly, but I can't find the reverse
possibility.
The only think I have found is the MethodHandle function of MethodInfo
class, that theorically return the metadata, but I can't find a way to go
further.

Thanks.

Nov 17 '05 #2
Thanks for this response.

Unfortunatly, I work on .Net 1.1.
Is it a way to retrieve this byte array by another way ?

Thanks.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Ludovic,

In .NET 2.0, you will be able to call the GetMethodBody method on the
MethodInfo instance and get a MethodBody instance which will allow you
access to the IL as a byte array.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ludovic DE FREITAS" <Lu**************@discussions.microsoft.com> wrote in
message news:1F**********************************@microsof t.com...
Hello,

With reflection, is it a way to get (in managed code) the IL Code of a
method ?
I would like to retrieve for a Method, all the called inner Method.

I know how to Emit IL Code in assembly, but I can't find the reverse
possibility.
The only think I have found is the MethodHandle function of MethodInfo
class, that theorically return the metadata, but I can't find a way to go
further.

Thanks.


Nov 17 '05 #3
Ludovic,

Unfortunately, without opening up the assembly yourself and parsing
through it, I don't know if there is a way to get the body of the method.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ludovic DE FREITAS" <Lu**************@discussions.microsoft.com> wrote in
message news:78**********************************@microsof t.com...
Thanks for this response.

Unfortunatly, I work on .Net 1.1.
Is it a way to retrieve this byte array by another way ?

Thanks.
"Nicholas Paldino [.NET/C# MVP]" wrote:
Ludovic,

In .NET 2.0, you will be able to call the GetMethodBody method on the
MethodInfo instance and get a MethodBody instance which will allow you
access to the IL as a byte array.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ludovic DE FREITAS" <Lu**************@discussions.microsoft.com> wrote
in
message news:1F**********************************@microsof t.com...
> Hello,
>
> With reflection, is it a way to get (in managed code) the IL Code of a
> method ?
> I would like to retrieve for a Method, all the called inner Method.
>
> I know how to Emit IL Code in assembly, but I can't find the reverse
> possibility.
> The only think I have found is the MethodHandle function of MethodInfo
> class, that theorically return the metadata, but I can't find a way to
> go
> further.
>
> Thanks.


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
2
by: Martin Raychev | last post by:
Hi all, I have the following problem: I have a private method that returns a SqlDataReader. For this to work I have not to close the DB connection in the above method. I do this only to
0
by: Steve | last post by:
Hi All, I have a Python script that uses SOAPpy and I'm outputting all of the methods and info about the parameters... I'm having trouble getting information out of the __init__ parameter. ...
5
by: Archana | last post by:
Hi all, I am having application where i am downloading xml content using webrequest. my code is as below HttpWebRequest lWebRequest = (HttpWebRequest) WebRequest.Create(URL); HttpWebResponse...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
0
by: banderson777 | last post by:
Hello, I'm a bit new at in-depth IE programming, and am having a bit of trouble with a couple of IE browser extensions (getting them to talk to each other). The first one is a C++ Browser Helper...
0
by: Heshan Suri | last post by:
Hi, I have written a the following python code to analyse a function or a method. I am having a script which is having a python function (add) and a class (MyClass) with a method (multiply).When...
21
vikas251074
by: vikas251074 | last post by:
I am getting error while entry in userid field. When user enter his user id, an event is fired immediately and user id is verified using AJAX method. But I am getting error 'Object doesn't support...
14
AnuSumesh
by: AnuSumesh | last post by:
Hi all, I am writing one application using c# in which firstly I m getting impersonating the user and then i want to retrieve mapped Drives. But issue is when I am calling method in following...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.