What is equivalent to Assembly.GetEntryAssembly () in .NET Core?

In the .NET Framework, we can get the initial assembly using:

Assembly.GetEntryAssembly(); 

But this is being removed from .NET Core. Also there is no AppDomain. How can I access assembly records in .NET Core and Windows Universal applications?

(I need to find all its built-in resource keys)

+6
source share
2 answers

As a result, I introduced the assembly of records in the library.

In library

 class AssemblyHelper { // This can be called instead of Assembly.GetEntryAssembly() public static Func<Assembly> GetEntryAssembly; } 

In the startup application (which uses the library):

 class Program { public static void Main() { AssemblyHelper.GetEntryAssembly = () => typeof(Program).GetAssembly(); .... } } 
-one
source

Assembly.GetEntryAssembly() is available in .NET Standard 1.5, but not in versions 1.0 through 1.4. If you are only developing .NET Core and Universal Windows applications, version 1.5 should be sufficient for your needs.

If I remember correctly, AppDomain should appear in .NET Standard 2.0. It is unavailable now.

+7
source

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


All Articles