Visual Studio 宏中的组合框

发布于 2024-11-24 15:30:39 字数 809 浏览 3 评论 0原文

当您需要调试托管在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满意归宿 2024-12-01 15:30:39

您可以打开一个对话框,但这不是最简单的事情。您需要将所有 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文