Get Executing Assembly Name in .net core
11,161
If it is above .NetCore 1.5 you can either use the following:
System.Reflection.Assembly.GetExecutingAssembly();
or (depending on your usecase):
System.Reflection.Assembly.GetCallingAssembly();
Don't forget to import the library:
using System.Reflection;
Related videos on Youtube
Author by
Haseeb Asif
Software Engineer .Net, asp.net, C#, SQL Server, HTML , JavaScript, Durandal, Knockout, lodash, CSS, less CSS, Python, Apache Kafka
Updated on June 04, 2022Comments
-
Haseeb Asif almost 2 years
I have a legacy class library targeting netstandard1.2 where we need to get the assembly name where this library is referenced.
Using the following give us the name of class library and it works fine.
typeof(MyHelperClass).GetTypeInfo().Assembly
but we need to get the referenced assembly name. Following code will work fine for standard .net but not for .net core
Assembly.GetEntryAssembly().GetName().Name;
Is there a way to get the executing assembly name using .net core while targeting .net standard 1.2?
-
Jeppe Stig Nielsen about 6 yearsStrongly related: What is the equivalent of Assembly.GetEntryAssembly() in .NET Core?
-
-
JasonDWilson about 5 yearsI get the name of the the library using both Assembly.GetEntryAssembly().GetName().Name and Assembly.GetExecutingAssembly().GetName().Name where I need the root application that called the library...
-
Cosmin about 5 years@JasonDWilson, try Assembly.GetCallingAssembly(); That worked for me.