473,387 Members | 3,801 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.

dynamically analyzing dlls for code resuse

Hi all...

At my work, we have a large number of dlls. Each dll is typically a
single class, and each class has any number of methods in it. We have
"core" objects that generally contain reuseable code, as well as
application-specific objects which usually make use of our core
objects.

What I'd like to do is get some sort of count to see how often our core
objects are used by our applications.

For example, say we have the following objects making calls:

"-->" means "calls a method in"

App1 --> Core1 --> Core2
App1 --> Core1 --> Core3
App2 --> Core1
App3 --> Core2

If I use Reflection, I can easily load up App1, and see that it depends
on Core1. I can then load up Core1 and see that it depends on Core2
and Core3 (and perhaps others)

However, I'd also like to know that App1 depends indirectly on Core2
and Core3.

Conversely, when I load up App2, I'd like to see that it's dependant on
(or, at least, calls a method in) Core1, but does NOT actually
need/use/touch Core2 or Core3.

Does that make sense?

I somehow need to trace actual method calls and keep a running count of
what objects are touched. Just finding out dependancies isn't good
enough (it either includes too much or not enough information).

Any ideas?

I think reflection isn't useful here. One thought is to use ILDASM to
disassemble every dll, and then parse the output. Possible, but it
seems like a mess.

What I'd really like some sort of diassembler that I access
programatically... so that I could load up a type, load up a method,
see who it calls, and then load up the target assembly/method, and
trace through it that way (a depth first search, basically).

Thanks for any help/advice you might have!

Adam

May 16 '06 #1
3 2376
Check out http://msdn.microsoft.com/msdnmag/issues/06/03/TestRun/ and
see if it is of any help

May 17 '06 #2
Thanks... that definitely looks like it's on the right track. I have
Reflector, and was pleasantly surprised to hear there was an API for
it.

However, the sample code in the MSDN article doesn't compile for me...

IServiceProvider serviceProvider = new Application(null);
IAssemblyLoader assemblyLoader = (IAssemblyLoader)
serviceProvider.GetService(typeof(IAssemblyLoader) );
IAssembly rAssembly =
assemblyLoader.LoadFile("..\\..\\..\\CombinationsL ib.dll");
The compiler doesn't know what "Application" is, as well as
IAssemblyLoader.

I'll keep poking around and see what I can do. Thanks for the lead,
and if anyone has any further thoughts, I appreciate it!

Adam

May 17 '06 #3
PS: Could IAssemblyLoader have been replaced with IAssemblyManager?
IAssemblyLoader doesn't seem to exist in the Reflector API (I believe I
have the latest version (4.2.42)), and IAssemblyManager has a LoadFile
method...

This is still giving me trouble, though... I've never used
IServiceProvider...

IServiceProvider serviceProvider = new Application(null);

May 17 '06 #4

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

Similar topics

1
by: Domer | last post by:
In my program, I load dynamically a DLL and I'm able to get a function pointer of type "int (__cdecl *)(void)" of any function in the DLL. If a DLL has a static class function, which calls the...
3
by: Benny Raymond | last post by:
Does anyone know off hand if dynamically compiled C# is debuggable in ..net 2.0?
4
by: Ryan Liu | last post by:
Can I create an enum dynamically in the code, e.g. data base driven? Thanks! Ryan
6
by: Dan Dorey | last post by:
I actually have two questions here, but I'll start by giving an outline of what I'm trying to do. I'm building an app with a simple plugin architecture (all in the same app domain). I have each...
2
by: 20050407 prerelease | last post by:
Hi! Is it possible in a fairly portable manner to load additional javascript code from a WWW URL? This would be useful for large-scale projects.
12
by: Zach | last post by:
Hi, I am making changes to a few modules of code and wish to test to see if my changes have made any increases in memory utilization, execution speed etc... The code is part of a server so lots...
2
by: David McCallum | last post by:
I'm not infront of my computer just now, but I seem to remember when my app is being executed the output console shows all the DLLs being loaded. Is there anyway to load these DLLs as and when...
3
by: jowharshamshiri | last post by:
i need to call a function that is saved in a .bas file on disk. the problem is i dont want to add the .bas module to my project. i need to run it through code dynamically at run time. can any one...
2
by: | last post by:
Hi, how can I combine some dynamically generated html code (using python) with the output of a urllib.openurl() call? I have tried to use the StringIO() class with .write functions, but it did...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.