Visual Studio中添加,以自动连接到开发服务器 [英] Visual Studio Add-In To Automatically Attach to Development Server

查看:478
本文介绍了Visual Studio中添加,以自动连接到开发服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是任何人都知道一个Visual Studio 2010加载项,它会自动让你连接到ASP.Net开发服务器的运行实例?如果有多个正在运行,显示一个对话框快,让你从列表的只是的正在运行的ASP.Net开发服务器?

Is anyone aware of a Visual Studio 2010 Add-In that will automatically allow you to attach to a running instance of the ASP.Net Development Server? And if there is more than one currently running, display a quick dialog that lets you choose from a list of just the ASP.Net Development Servers that are running?

为什么我要这样? < - 的随意跳过这一部分

Why do I want this? <-- feel free to skip this part.

我一般开发/调试Web应用程序的方法是,启动浏览器,并通过应用导航,直到我得到我想要的页面(可能还有很多深页)。我不希望有通过这些附加调试器由于各种原因(比没有它连接慢的步骤,多余的突破点可能会受到较大冲击,也许是我休息的时候甩打开并不愿意在应用早一点攻破时抛出处理的错误,等等。 。)

The way I usually develop / debug web applications is to launch a browser and navigate through the application until I get to the page I want (could be many pages deep.) I don't want to have the debugger attached through these steps for various reasons (it is slower than not having it attached, extraneous break-points may be hit, I may have break when "thrown" turned on and not want to break earlier in the app when handled errors are thrown, etc...)

我浏览到我想要的页面,然后使用Visual Studio菜单调试>从内部附加到进程对话框,我要一路向下滚动附加到进程,然后(页面和页面和流程页面),直到我找到WebDev.WebServer40.EXE过程中,我想和选择。

I navigate to the page I want, then use the Visual Studio menus to Debug > Attach to Process, and then from within the Attach to Process dialog, I have to scroll all the way down (pages and pages and pages of processes) until I find the WebDev.WebServer40.EXE process I want and choose that.

这样做让我把我的手离开键盘和使用鼠标(东西我一般尽量避免。)

Doing this makes me take my hands off the keyboard and use a mouse (something I generally try to avoid.)

和这样做似乎不必要的重复,因为,如果我调试ASP.Net Web应用程序,我总是要附加到WebDev.WebServer40.exe的一个实例。

And doing this seems needlessly repetitive since, if I am debugging an ASP.Net Web Application, I always want to attach to an instance of the WebDev.WebServer40.exe.

推荐答案

我preFER做同样的事情,它的可能给它的所有绑定到一个宏按键。

I prefer to do the exact same thing and it IS possible to bind it all to a keystroke with a macro.

转到工具>宏>宏IDE

Goto Tools > Macros > Macro IDE

添加一个新的模块,并使用此code(时髦的注释语法加亮)

Add a new module and use this code (the funky comments are for syntax highlighting)

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Collections.Generic

Public Module AttachingModule
    Sub AttachToAspNET()
        Try
            Dim process As EnvDTE.Process

            Dim listProcess As New List(Of String)
            '' // uncomment the processes that you'd like to attach to.  I only attach to cassini
            '' // listProcess.Add("aspnet_wp.exe")
            '' // listProcess.Add("w3wp.exe")
            listProcess.Add("webdev.webserver")

            For Each process In DTE.Debugger.LocalProcesses
                For Each procname As String In listProcess
                    If process.Name.ToLower.IndexOf(procname) <> -1 Then
                        process.Attach()
                    End If
                Next
            Next

        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try
    End Sub

End Module

点击文件>关闭并返回

点击工具>选项

点击环境>键盘

我把MyMacros宏,所以我在寻找Macros.MyMacros.AttachingModule.AttachToAspNET,显示命令包含文本框。

I put the macro in MyMacros, so I look for "Macros.MyMacros.AttachingModule.AttachToAspNET" in the "Show Commands Containing" textbox".

我preFER使用<大骨节病>控制 + <大骨节病>替代 + <大骨节病> D 但放在任何你想要的preSS快捷键文本框,单击分配,然后确定

I prefer to use Ctrl+Alt+D but put whatever you want in the "Press Shortcut Keys" textbox and click Assign, then OK

现在你需要做的就是按<大骨节病>控制 + <大骨节病>替代 + <大骨节病> D 附加到所有卡西尼实例。

Now all you have to do is hit Ctrl+Alt+D to attach to all cassini instances.

我见过的这个不同版本围绕互联网和<一个href=\"http://stackoverflow.com/questions/2512935/visual-studio-attach-to-particular-instance-of-the-process-macro\">this是最近我发现。我只好稍微修改删除多余的网络流程和下降从 WebDev.WebServer.exe .exe文件,所以,这将调试.NET卡西尼4.0实例。

I've seen various versions of this around the internets and this was the most recent I found. I had to modify that slightly to remove the extra web processes and to drop the .exe from WebDev.WebServer.exe, so that it would debug .net 4.0 instances of cassini.

这篇关于Visual Studio中添加,以自动连接到开发服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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