本文介绍了如何获得真实的运行进程名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 .NET 核心控制台应用程序中,我想获取正在运行的进程名称,我使用了
Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().ProcessName);
打印This is my name,如下所示.
任务管理器显示
[assembly: AssemblyTitle("This is my name Title")]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 core you could use:
System.Reflection.Assembly.GetEntryAssembly().FullNameor
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")]更多推荐
如何获得真实的运行进程名称?
发布评论