如何设置项目的可执行进程名?
我想让我的可执行文件的进程被称为 ABC。 我怎样才能做到这一点? 我尝试将项目名称定义为 ABC,但随后我将拥有 ABC.vshost。
I'd like to have my executable's process be called ABC. How I can do this? I tried defining my project name as ABC, but then I'll have an ABC.vshost.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以在项目的属性页面中进行设置。 在应用程序选项卡上设置程序集名称将设置生成的编译程序集的名称(即 ABC.exe)。
.vshost.exe 是 Visual Studio 调试进程,由 Visual 使用调试时的工作室。 您可以通过取消选中项目属性的调试选项卡上的“启用 Visual Studio 托管进程”复选框来关闭它(Visual Studio 不需要它来调试)。
You can set this in the project's properties page. Setting the assembly name on the application tab will set the name of the resulting compiled assembly (ie. ABC.exe).
The .vshost.exe is the Visual Studio debugging process, used by Visual Studio when you debug. You can turn that off (Visual Studio does not need it to debug) by unchecking the "enable the visual studio hosting process" checkbox on the debug tab of the the project properties.
单独更改“程序集名称”对我没有帮助。更改 AssemblyInfo.cs 文件中的程序集标题帮助我更改进程名称。
Changing "Assembly name" alone did not help me.Changing Assembly title in AssemblyInfo.cs file helped me to change process name.
您能做的最好的事情就是将属性页(解决方案资源管理器中的“属性”节点)中的程序集名称设置为您想要的任何名称。 C# 编译器自动使用程序集名称作为进程名称(生成的 EXE 的文件名),因此这应该可以为您完成这项工作。 请注意,程序集名称完全独立于项目名称和根命名空间。
当然,您可以在生成 EXE 后更改它的文件名(这将使程序集名称保持不变),尽管我看不出这样做的真正原因。
注意:我假设您特别指的是 Visual Studio,尽管就可能性而言,它可能并不重要。
The best you can do is to set the assembly name in the property pages (Properties node in Solution Explorer) to whatever you wish. The C# compiler automatically uses the assembly name as the process name (file name of the generated EXE), so this should do the job for you. Note that the assembly name is completely independent from the project name and the root namespace.
You can of course change the file name of the EXE after it has been generated (and this will leave the assembly name unchanged), though I see no real reason for this.
Note: I assume you are referring to Visual Studio in particular, though it probably matters little in terms of what is possible.
它似乎是从 .EXE 的版本信息资源中获取的; 具体来说,是“FileDescription”属性。 要以编程方式执行此操作,我想您需要一个单独的程序来更新 .EXE 中您要更改其描述的版本信息资源。 (我不懂 C#,但在 C++ 中,UpdateResource 用于此目的。)
It seems it's taken from the version-info resource for an .EXE; specifically, the "FileDescription" attribute. To do this programmatically, I imagine you would need a separate program to update the version-info resource in the .EXE whose description you're trying to change. (I don' know C#, but in C++, UpdateResource is used for this purpose.)
任务管理器中的进程名称基于映像名称,该映像名称是可执行文件(正如已经指出的程序集名称设置在 VS.Net 中定义了这一点)。
应用程序名称基于窗口标题,因此只能使用图形应用程序进行更改(除非通过对控制台进行肮脏的黑客攻击,这不太可能稳定)。
请注意,您可以拥有多个可执行文件,它们都在共享 dll 中执行公共 main 方法,因此您可以以不同的方式“命名”本质上相同的代码的不同实例(如果有帮助的话)。
The processes name in task manager is based of the image name, which is the executable (as already pointed out the assembly name setting defines this in VS.Net).
The Application Name is based on the window title, so is only something you can alter with graphical apps (except via dirty hacks to the console which are unlikely to be stable).
Note that you can have multiple executables all executing a common main method in a shared dll so you can 'name' different instances of essentially the same code differently if that helps.