Visual Studio 宏中的组合框
当您需要调试托管在 IIS Express 上的网站时,每次需要重建代码时,通常不会重新启动它。您只需将 VS 附加到该进程即可。宏脚本有很大帮助:
Public Module AttachToProcess
Public Sub AttachToWebServer()
Dim attached As Boolean = False
Dim proc As EnvDTE.Process
For Each proc In DTE.Debugger.LocalProcesses
If (Right(proc.Name, 14) = "iisexpress.exe") Then
proc.Attach()
attached = True
Exit For
End If
Next
If attached = False Then
MsgBox("iisexpress.exe is not running")
End If
End Sub
End Module
您可以指定击键,瞧。唯一的问题是,如果您的解决方案包含多个 Web 应用程序,则会有多个具有不同 PID 的 iisexpress.exe 进程,而 VS 有时会选择错误的进程。
问题:如果有多个iisexpress.exe运行,是否可以弹出一个对话框来选择正确的一个?
当然,您始终可以使用默认的“附加到进程”对话框,但它不会像使用该脚本和键盘快捷键那么快。
When you need to debug a Website that hosts on IIS Express, you usually don't restart it all over again, every time when you need to rebuilt your code. You just attach VS to the process. And the macros script helps a lot:
Public Module AttachToProcess
Public Sub AttachToWebServer()
Dim attached As Boolean = False
Dim proc As EnvDTE.Process
For Each proc In DTE.Debugger.LocalProcesses
If (Right(proc.Name, 14) = "iisexpress.exe") Then
proc.Attach()
attached = True
Exit For
End If
Next
If attached = False Then
MsgBox("iisexpress.exe is not running")
End If
End Sub
End Module
You can assign a keystroke and voila. The only problem is if your solution contains more than one webapp, there would be more than one iisexpress.exe processes with different PIDs, and VS would sometimes choose the wrong one.
The question: Is it possible to popup a dialog if there is more than one iisexpress.exe running to choose the right one?
Of course you can always use default 'Attach To Proccess' dialog, but it's not gonna be as quick as using that script and keyboard shortcut.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以打开一个对话框,但这不是最简单的事情。您需要将所有 UI 代码放入宏、EG 布局、控件大小等中...
大约有 200 行代码,我不会将其全部放在这里,而是将您转到我的博客 http://www.brianschmitt.com/2010/09/save-and-change-tool-layout-in-visual.html
您应该能够重用“视图切换器”对话框并列出 IISExpress 的所有实例。做你需要做的事情应该不需要太多。
You can open a dialog, but it's not the most straightforward thing. You will need to put all your UI code into the macro, EG layout, size of controls, etc...
It's about 200ish lines of code, and rather than put it all here I will defer you to my blog at http://www.brianschmitt.com/2010/09/save-and-change-tool-layout-in-visual.html
You should be able to reuse the View Switcher dialog box and list out all instances of IISExpress. It shouldn't take much to do what you need it to.