如何获得真实的运行进程名称?

编程入门 行业动态 更新时间:2024-10-26 22:17:02
本文介绍了如何获得真实的运行进程名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在 .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().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")]

更多推荐

如何获得真实的运行进程名称?

本文发布于:2023-11-16 02:12:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1600061.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   进程   名称   真实

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!