How to get real running process name?

最后都变了- 提交于 2019-12-22 12:27:24

问题


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

回答1:


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")]



来源:https://stackoverflow.com/questions/45227716/how-to-get-real-running-process-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!