调试期间,在Visual Studio中自动附加到子进程 [英] Attaching to a child process automatically in Visual Studio during Debugging
问题描述
当编写插件给你的插件是在美国举行 ehexthost.exe
此exe会从 ehshell.exe
你有没有办法直接启动它,而不是你通过一个特殊的参数,以 ehshell.exe
这将启动插件在单独的进程。
When writing plugins for media center your plugin is hosted in ehexthost.exe
this exe gets launched from ehshell.exe
and you have no way of launching it directly, instead you pass a special param to ehshell.exe
which will launch the plugin in a separate process.
当我们正在调试媒体的浏览器我发现的过程附加到第二个进程那种笨重,我知道Debugger.Attach,也是一些特殊的注册表项我可以使用。
When we are debugging media browser I find the process of attaching to a second process kind of clunky, I know about Debugger.Attach and also of some special registry entries I can use.
这两种方法并不完全适合我的法案。我要的是preSS F5和有Visual Studio我目前的情况下自动附加到子进程。可以这样做?
Both these methods don't exactly fit my bill. What I want is to press F5 and have my current instance of visual studio attach to the child process automatically. Can this be done?
如果有是VS的一个插件,可以让我实现这个功能,我会很高兴的。
If there is a plugin for VS that allows me to achieve this functionality I would be happy with it.
修改
我结束了与下面的宏会:</ P>
I ended up going with the following macro:
Public Sub CompileRunAndAttachToEhExtHost()
DTE.Solution.SolutionBuild.Build(True)
DTE.Solution.SolutionBuild.Debug()
Dim trd As System.Threading.Thread = New System.Threading.Thread(AddressOf AttachToEhExtHost)
trd.Start()
End Sub
Public Sub AttachToEhExtHost()
Dim i As Integer = 0
Do Until i = 50
i = i + 1
Try
For Each proc As EnvDTE.Process In DTE.Debugger.LocalProcesses
If (proc.Name.IndexOf("ehexthost.exe") <> -1) Then
proc.Attach()
Exit Sub
End If
Next
Catch e As Exception
' dont care - stuff may be busy
End Try
Threading.Thread.Sleep(100)
Loop
End Sub
另外,我概括的过程如何的得到这个打算在我的博客。
推荐答案
我会用一个宏。我已经重新定义了我的F5功能附加到asp.net的过程,而不是漫长的构建/验证它通常执行。此工程pretty的很适合我,这真的很容易。
I would use a macro. I've redefined my F5 function to attach to the asp.net process instead of the long build/validate it usually performs. This works pretty well for me and it's really easy.
For Each process In DTE.Debugger.LocalProcesses
If (process.Name.IndexOf("aspnet_wp.exe") <> -1) Then
process.Attach()
Exit Sub
End If
Next
这篇关于调试期间,在Visual Studio中自动附加到子进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!