Runtime: AppDomain.CurrentDomain.GetAssemblies() Problem

Created on 25 Oct 2017  路  2Comments  路  Source: dotnet/runtime

Hello,

I am using the function AppDomain.CurrentDomain.GetAssemblies() to load all the assemblies that are in my project. Based on that I have further logic to do some stuff which is not important for purpose of this problem.

I call this in Startup class under ConfigureServices method. I have a nuget package added to my project called MyProject.Email (1.0.0). When I debug and look at the list of assemblies that are supplied to me, I don't see my assembly in that list. There are about 117 assemblies and none of them is my assembly. This package is referenced directly in the project (not via another project) and I can see the dll inside the bin folder.

Is there a known bug that will skip loading an assembly or is there another method in core that will get ALL assemblies?

area-AssemblyLoader-coreclr question

Most helpful comment

To enumerate all assemblies that the app is composed from, look at Microsoft.Extensions.DependencyModel. E.g. foreach (var l in Microsoft.Extensions.DependencyModel.DependencyContext.Default.RuntimeLibraries) Console.WriteLine(l.Name); will print names of all assemblies that the app is composed from. However, loading all assemblies that the app is composed from tends to scale poorly with size of the application and results in slow startup.

All 2 comments

AppDomain.CurrentDomain.GetAssemblies() does not load any assemblies. It will only return assemblies that are loaded already. https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.getassemblies?view=netcore-2.0#System_AppDomain_GetAssemblies

To enumerate all assemblies that the app is composed from, look at Microsoft.Extensions.DependencyModel. E.g. foreach (var l in Microsoft.Extensions.DependencyModel.DependencyContext.Default.RuntimeLibraries) Console.WriteLine(l.Name); will print names of all assemblies that the app is composed from. However, loading all assemblies that the app is composed from tends to scale poorly with size of the application and results in slow startup.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iCodeWebApps picture iCodeWebApps  路  3Comments

nalywa picture nalywa  路  3Comments

GitAntoinee picture GitAntoinee  路  3Comments

btecu picture btecu  路  3Comments

EgorBo picture EgorBo  路  3Comments