Assembly.GetExecutingAssembly().GetReferencedAssemblies()

  • Thread starter Thread starter David Laub
  • Start date Start date
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()
 
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
 
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.
--------------------
 
Back
Top