Assembly.GetExecutingAssembly().GetReferencedAssemblies()

D

David Laub

It appears that getting a list of a program's referenced assemblies is a
dynamic/run-time facility.

If I execute GetReferencedAssemblies immediately in a console app, the only
assemblies returned are the app itself and mscorlib

If I (recursively) execute GetReferencedAssemblies after methods in
referenced assemblies have been resolved/executed, then I get a far more
meaningful list

I would really like a method which reflects the "full" static reference list
in the c# project file. Does such a method exist, or is there a good way to
simulate this?

Thanks

David Laub (e-mail address removed)





Assembly.GetExecutingAssembly().GetReferencedAssemblies()
 
M

Mattias Sjögren

David,
I would really like a method which reflects the "full" static reference list
in the c# project file. Does such a method exist, or is there a good way to
simulate this?

The C# compiler only writes AssemblyRef records (which is what
GetReferencedAssemblies retrieves) for assemblies that you actually
use. If you reference a bunch of assemblies that you don't use in your
code, that will not be seen in the compiled assembly. The only way to
discover such references would be to parse the .csproj project file.



Mattias
 
G

Guest

This is the same information as shown by ildasm.exe in the "Manifest".

Shri Borde [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top