Can I get all the assemblies referenced by the website

Basically, I want to print the list on a page inside my MVC site, which shows all the assemblies that are used by the application, and there is version information.

I don’t want to just include bin in the directory, I want to use a more precise way.

So the examples would be

I want to know which DLL in the bin directory is used. For each of them, I need to see what their dependent assemblies are (with their version information).

I want to know which dll is referenced from the GAC, etc.

I want as much information as possible about this, so information such as the expected build and what the application is typing would be useful.

Are there any standard approaches to this?

Thanks Martin

+4
source share
2 answers

Consider using BuildManager.GetReferencedAssembliesone that:

Returns a list of assembly links that should reference all page compilations.

Usage example:

var assemblies = BuildManager.GetReferencedAssemblies().Cast<Assembly>();

Note also the important difference between this method and AppDomain.GetAssemblies(). BuildManager.GetReferencedAssembliesreturns:

specified in the assembly element of the Web.config file, assemblies created from user code in the App_Code directory, and assemblies in other top-level folders.

while AppDomain.GetAssemblies()returns only currently loaded assemblies.

+5
source

Try the following:

var assemblies = AppDomain.CurrentDomain.GetAssemblies();
0
source

Source: https://habr.com/ru/post/1538042/


All Articles