如何获得真实的运行进程名称? [英] How to get real running process name?
本文介绍了如何获得真实的运行进程名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在.NET Core控制台应用程序中,我想获取运行的进程名称,我使用了
Console.WriteLine(System.Diagnostics.Process .GetCurrentProcess()。ProcessName);
打印这是我的名字
,如图所示
任务管理器显示
[程序集:AssemblyTitle(这是我的名字标题)]
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")]
这篇关于如何获得真实的运行进程名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文