Sam*_*ron 36 .net c# debugging visual-studio visual-studio-debugging
在为媒体中心编写插件时,你的插件会被托管在ehexthost.exe这个exe中ehshell.exe,你无法直接启动它,而是你传递了一个特殊的参数ehshell.exe,它将在一个单独的进程中启动插件.
当我们调试媒体浏览器时,我发现附加到第二个进程的过程有点笨重,我知道Debugger.Attach以及我可以使用的一些特殊注册表项.
这两种方法都不符合我的法案.我想要的是按F5并让我当前的visual studio实例自动附加到子进程.可以这样做吗?
如果有一个VS的插件允许我实现这个功能,我会很高兴.
编辑
我最终使用以下宏:
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
另外,我概述了如何在我的博客上进行此操作的过程.
Jab*_*Jab 38
我会用一个宏.我重新定义了我的F5函数来附加到asp.net进程,而不是它通常执行的长版本/验证.这对我很有用,而且非常简单.
    For Each process In DTE.Debugger.LocalProcesses
        If (process.Name.IndexOf("aspnet_wp.exe") <> -1) Then
            process.Attach()
            Exit Sub
        End If
    Next
Mik*_*ain 14
对于VS2012,宏已被删除,但您仍然可以使用标准键盘快捷键快速完成.例如,要附加到iisexpress.exe:
Ctrl+ Alt+ p- 打开Attach To Process对话框
i - 跳转到列表中以i开头的第一个进程(对我来说这是iisexpress.exe)
Enter - 附上
对于超高速,您还可以在调试IIS时关闭Visual Studio Attach安全警告.
| 归档时间: | 
 | 
| 查看次数: | 19235 次 | 
| 最近记录: |