在调试期间在Visual Studio中自动附加到子进程 [英] Attaching to a child process automatically in Visual Studio during Debugging

查看:460
本文介绍了在调试期间在Visual Studio中自动附加到子进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为媒体中心编写插件时,您的插件托管在 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.

这两种方法都不完全符合我的账单。我想要的是按F5并将我当前的可视化实例实例自动附加到子进程。这可以做吗

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.

编辑

我最后使用以下宏:

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

此外,我概述了如何得到这个

Also, I outlined the process on how to get this going on my blog.

推荐答案

我会使用一个宏。我重新定义了我的F5函数来附加到asp.net进程,而不是通常执行的long build / validate。这对我来说很好,这很简单。

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屋!

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