6

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
Athari
  • 33,702
  • 16
  • 105
  • 146
fluter
  • 13,238
  • 8
  • 62
  • 100
  • 1
    What does `System.AppDomain.CurrentDomain.FriendlyName` return? It is [from here](https://stackoverflow.com/a/616715/6741868). – Keyur PATEL Jul 21 '17 at 01:53
  • It is the right name I wanted, so this is hold in AppDomain not Process, thanks! – fluter Jul 21 '17 at 01:57

1 Answers1

8

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'

enter image description here

Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().ProcessName);

prints This is my name as shown below.

enter image description here

Task Manager displays

 [assembly: AssemblyTitle("This is my name Title")]

enter image description here

tymtam
  • 31,798
  • 8
  • 86
  • 126