为什么 AppDomain.CurrentDomain.SetupInformation.ApplicationName 返回 exe 文件的 svhost 版本

发布于 2024-11-26 13:56:13 字数 593 浏览 1 评论 0原文

我正在使用方法 AppDomain.CurrentDomain.SetupInformation.ApplicationName 来获取可执行文件名,但我得到的不是这个名称

Appname.svhost.exe

,而是应该是:

Appname.exe

为什么是这样?

更新

因此,当 Visual Studio 打开时,它会保留 Appname.svhost.exe 用于调试目的 + Appname.exe 如果我运行应用程序。所以我关闭了 Visual Studio 并运行应用程序,在这种情况下 AppDomain.CurrentDomain.SetupInformation.ApplicationName 正在做这件事。但问题是,当项目打开时,是否可以使用 AppDomain.CurrentDomain.SetupInformation.ApplicationName 返回 Appname.exe ?为什么会出现这样的行为?

I am using method AppDomain.CurrentDomain.SetupInformation.ApplicationName to get executable file name but instead of that i am getting

Appname.svhost.exe

but should be:

Appname.exe

Why it is like that?

UPDATE

So when when visual studio opened it is keeping Appname.svhost.exe for debugging purposes + Appname.exe if i run application. SO i closed visual studio and run app, in that case AppDomain.CurrentDomain.SetupInformation.ApplicationNamedoing the thing. But the question is is it possible to get return Appname.exe with AppDomain.CurrentDomain.SetupInformation.ApplicationName when project opened? and why it is such behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

捂风挽笑 2024-12-03 13:56:13

尝试:

String ExePath = System.Windows.Forms.Application.ExecutablePath
String ExeFile = System.IO.Path.GetFileName(ExePath)
// ExePath = "C:\Users\You\Documents\Visual Studio 2010\Projects\MyProject\bin\Debug\AppName.exe"
// ExeFile = "AppName.exe"

Try:

String ExePath = System.Windows.Forms.Application.ExecutablePath
String ExeFile = System.IO.Path.GetFileName(ExePath)
// ExePath = "C:\Users\You\Documents\Visual Studio 2010\Projects\MyProject\bin\Debug\AppName.exe"
// ExeFile = "AppName.exe"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文