473,387 Members | 1,863 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,387 software developers and data experts.

Reflection and Find all references

I want to develop a small utility similar to the "Find all References" in
Visual Studio so that I can determines if methods in a library are actually
being used inside an exe assembly. It is easy enough to find all the public
methods in the library, but how do I find if a particular method is being
called in the exe assembly? Does anyone have a code example?
Jan 4 '08 #1
2 3985
It's not really that easy. You will have to get a MethodInfo instance
for all the methods in the assembly, for every type, every property get and
set, every event add and remove.

Once you have that IL, you will have to parse the IL byte stream and
call the ResolveMethod instance on the Module instance that the type being
examined is in, and look to see if the instance corresponds to the
MethodInfo for your method that you are trying to determine the use of.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"JeffinPittsburgh" <Je**************@discussions.microsoft.comwrote in
message news:4B**********************************@microsof t.com...
>I want to develop a small utility similar to the "Find all References" in
Visual Studio so that I can determines if methods in a library are
actually
being used inside an exe assembly. It is easy enough to find all the
public
methods in the library, but how do I find if a particular method is being
called in the exe assembly? Does anyone have a code example?

Jan 4 '08 #2
Hello JeffinPittsburgh,

do you mean stuff like this:
http://www.lesser-software.com/lswdnrb.htm

I want to develop a small utility similar to the "Find all References"
in Visual Studio so that I can determines if methods in a library are
actually being used inside an exe assembly. It is easy enough to find
all the public methods in the library, but how do I find if a
particular method is being called in the exe assembly? Does anyone
have a code example?

Jan 4 '08 #3

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

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
4
by: Jimi | last post by:
Given a C# project file path, can I use reflection to get all the assemblies referenced by the project? e.g., I know the path of a C# project, say, "c:\SomeProject.csproj", and I want to load...
7
by: Allan Ebdrup | last post by:
How do I get hold of the type when I have a string that represents the type. For example I have the string "OFiR.Recruitment.Department" And I want to get the type called...
7
by: Nemisis | last post by:
Hi everyone, Can anyone tell me if it is possible to pass in a property of an object into a sub, and within that sub, find out the name of the item that was passed along with the property name??...
6
by: alexbf | last post by:
Hello, I would like to know if it's possible using reflection to loop through all "web references" of a given assembly and get the url as specified in the web.config (dynamic url behavior). ...
5
by: | last post by:
I am having problems with casting or converting a class to to an interface from which it derives. I'm certain that it's due to how it's being loaded, but I'm not sure how to get past the problem....
3
by: Hugh Oxford | last post by:
Hi Folks, Is there any way of using reflection to find out what classes other classes use? I do not mean which classes extend other classes, I mean within methods, for example, where the...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.