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.
当为媒体中心编写插件时,你的插件在ehexthost托管。exe这个exe从ehshell启动。exe无法直接启动,而是将一个特殊的参数传递给ehshell。exe,它将在一个单独的进程中启动插件。
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.
当我们调试媒体浏览器时,我发现附加到第二个进程的过程有点笨拙,我知道调试器。附加以及一些我可以使用的特殊注册表项。
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?
这两种方法都不太符合我的要求。我想要的是按F5,让我当前的visual studio实例自动附加到子进程。这个可以做吗?
If there is a plugin for VS that allows me to achieve this functionality I would be happy with it.
如果VS有一个插件允许我实现这个功能,我会很高兴的。
EDIT
编辑
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
Also, I outlined the process on how to get this going on my blog.
此外,我还概述了如何在我的博客上进行这项工作的过程。
5 个解决方案
#1
38
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.
我会使用宏。我重新定义了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
#2
14
For VS2012, macros have been dropped, but you can still do it quite quickly with standard keyboard shortcuts. For instance, to attach to iisexpress.exe:
对于VS2012,宏已经被删除,但是您仍然可以使用标准的键盘快捷键来快速执行。例如,附加到iisexpress。exe:
Ctrl + Alt + p - brings up the Attach To Process dialog
Ctrl + Alt + p -弹出进程附加对话框
i - jumps to the the first process beginning with i in the list (for me this is iisexpress.exe)
i -跳转到第一个进程,以列表中的i开头(对我来说,这是iisexpress.exe)
Enter - attaches
输入——高度
For super speed, you can also Turn off Visual Studio Attach security warning when debugging IIS.
对于超级速度,您还可以在调试IIS时关闭Visual Studio Attach安全警告。
#4
2
I was debugging a C++ plugin in an externally spawned process that crashed by throwing an exception at startup and this worked perfectly for me:
我正在一个外部衍生的进程中调试一个c++插件,这个进程在启动时抛出一个异常而崩溃,这对我来说非常有效:
Add the free Reattach Extension for Visual Studio. Ask it to reattach to the process name before it is launched. It will pop a modal dialog saying it is waiting for the process name to launch.
为Visual Studio添加免费的Reattach扩展。请求它在进程名启动之前重新附加到进程名。它将弹出一个模态对话框,表示它正在等待进程名的启动。
Now launch the process and the Visual Studio debugger will attach immediately, catching exceptions and hitting breakpoints.
现在启动进程,Visual Studio调试器将立即附加,捕获异常并命中断点。
(This was also in a media plugin, the exception was normally caught and rethrown by the host process in a Delphi context so I needed to break before that happened).
(这也是在一个媒体插件中,异常通常在Delphi上下文中被主机进程捕获并重新抛出,所以我需要在此之前中断)。
#5
0
You can automatically attach to a process by pressing F5, if you setup something like that in visual studio:
你可以通过按F5自动附加到一个进程,如果你在visual studio中设置了类似的东西:
http://vvcap.net/db/ujYL7zeN_n_RgeprqCSM.htp
http://vvcap.net/db/ujYL7zeN_n_RgeprqCSM.htp
notice: There's "Command" filled up as an executable name, and "Attach" must be "yes"
注意:“命令”填充为可执行名称,“附加”必须是“yes”
#1
38
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.
我会使用宏。我重新定义了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
#2
14
For VS2012, macros have been dropped, but you can still do it quite quickly with standard keyboard shortcuts. For instance, to attach to iisexpress.exe:
对于VS2012,宏已经被删除,但是您仍然可以使用标准的键盘快捷键来快速执行。例如,附加到iisexpress。exe:
Ctrl + Alt + p - brings up the Attach To Process dialog
Ctrl + Alt + p -弹出进程附加对话框
i - jumps to the the first process beginning with i in the list (for me this is iisexpress.exe)
i -跳转到第一个进程,以列表中的i开头(对我来说,这是iisexpress.exe)
Enter - attaches
输入——高度
For super speed, you can also Turn off Visual Studio Attach security warning when debugging IIS.
对于超级速度,您还可以在调试IIS时关闭Visual Studio Attach安全警告。
#3
#4
2
I was debugging a C++ plugin in an externally spawned process that crashed by throwing an exception at startup and this worked perfectly for me:
我正在一个外部衍生的进程中调试一个c++插件,这个进程在启动时抛出一个异常而崩溃,这对我来说非常有效:
Add the free Reattach Extension for Visual Studio. Ask it to reattach to the process name before it is launched. It will pop a modal dialog saying it is waiting for the process name to launch.
为Visual Studio添加免费的Reattach扩展。请求它在进程名启动之前重新附加到进程名。它将弹出一个模态对话框,表示它正在等待进程名的启动。
Now launch the process and the Visual Studio debugger will attach immediately, catching exceptions and hitting breakpoints.
现在启动进程,Visual Studio调试器将立即附加,捕获异常并命中断点。
(This was also in a media plugin, the exception was normally caught and rethrown by the host process in a Delphi context so I needed to break before that happened).
(这也是在一个媒体插件中,异常通常在Delphi上下文中被主机进程捕获并重新抛出,所以我需要在此之前中断)。
#5
0
You can automatically attach to a process by pressing F5, if you setup something like that in visual studio:
你可以通过按F5自动附加到一个进程,如果你在visual studio中设置了类似的东西:
http://vvcap.net/db/ujYL7zeN_n_RgeprqCSM.htp
http://vvcap.net/db/ujYL7zeN_n_RgeprqCSM.htp
notice: There's "Command" filled up as an executable name, and "Attach" must be "yes"
注意:“命令”填充为可执行名称,“附加”必须是“yes”