如何确定托管应用程序中的visual studio [英] How do I determine if visual studio in hosting application

查看:82
本文介绍了如何确定托管应用程序中的visual studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从应用程序发布模式确定Visual Studio是否托管它。



我尝试过:



我尝试过IsDebugger,但只有在应用程序从调试模式运行时才有效。

I want to determine from application release mode if Visual Studio is hosting it.

What I have tried:

I have tried IsDebugger, but that only works if application is running from Debug mode.

推荐答案

获取ID父进程并检查它的名称。如果它是 devenv.exe ,则您的程序已在VisualStudio中启动。



示例代码可在此SO线程中找到:

c# - 如何获取应用程序父进程的PID - Stack Overflow [ ^ ]
Get the ID of the parent process and check it's name. If it is devenv.exe, your program has been started from within VisualStudio.

Example code can be found at this SO thread:
c# - How can I get the PID of the parent process of my application - Stack Overflow[^]


这篇关于如何确定托管应用程序中的visual studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆