Thank you for interesting Question!
As I say, it's easy if you have the source code (Visual Studio can do it automatically). If not, I know only one method of doing it: disassemble all referencing assemblies in question and analyze the result of it. You can always use disassembler programmatically, all you need is the re-distributed .NET Framework.
(You should not use term "DLL". In contrast to native Windows, all .NET assemblies are essentially equal. You can reference
*.exe
in exact same way as
*.DLL
, did you know that?)
You should understand that you need to analyze referencing assemblies. The result on what is used on a referenced assembly depends on which assemblies use it. You should also understand the difference between methods that are statically known to be never called because there is no a calling code in the referencing assemblies. There are methods which can be called in principle (calling code exists) but are not called by the dynamic behavior of the running code. It easy to proof that sorting out such methods is theoretically unresolvable problem. The answer can be inferred from the well-know
halting problem
:
http://en.wikipedia.org/wiki/Halting_problem[
^], see also
http://en.wikipedia.org/wiki/Computability_theory[
^].
So, let's focus on the first, easier problem (static resolution).
As a side note, you should understand that method are JIT compiled only on demand. It means that even if you capture JIT compilation, it won't help you to solve the problem.
Unfortunately, to best of my knowledge, solving this problem using Reflection is not possible. Resolving assembly dependencies is way too, easy, you probably know that. That said, I'm not 100% sure that there is not solution. If you come across the way to solve the problem, please share.
Thank you.
—SA