In a .NET core console app, I'd like to get the running process name, I used ProcessName
as the docs say, but it always returns dotnet
as the process name, not the actual underline dll that is running. Although it is a dll, this is a console app, not a library.
Console.WriteLine(Process.GetCurrentProcess().ProcessName);
output
dotnet
EDIT:
For .net core you could use:
System.Reflection.Assembly.GetEntryAssembly().FullName
or
System.Reflection.Assembly.GetEntryAssembly().GetName().Name
For .NET
For a project with Assmebly Name 'This is my name'
Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().ProcessName);
prints This is my name
as shown below.
Task Manager displays
[assembly: AssemblyTitle("This is my name Title")]