简体   繁体   English

如何自动将VS附加到另一个进程进行调试?

[英]How to automatically attach VS to another process for debugging?

I'm debugging an ASP.NET application deployed on IIS 7.5 (VS 2010/Windows 7 x64).我正在调试部署在 IIS 7.5(VS 2010/Windows 7 x64)上的 ASP.NET 应用程序。 After I make changes, I have to deploy it to the IIS folder and then do the following things (anyone of you should already know, I just list to demonstrate how boring and time-consuming they are):进行更改后,我必须将其部署到 IIS 文件夹,然后执行以下操作(你们应该已经知道,我只是列出来演示它们是多么无聊和耗时):

  • Click on the Debug menu, choose Attach to Process单击调试菜单,选择附加到进程
  • From the list, choose Show processes in all sessions从列表中,选择 Show processes in all sessions
  • Choose the right w3wp.exe process选择正确的 w3wp.exe 进程
  • Click attach点击附加
  • Click attach again再次点击附加

well, it's load of unnecessary works.好吧,这是一堆不必要的工作。 Due to our system architect, this is the only way, we can debug straightforward by F5 button, but I wonder that if there's a workaround about this, so I can do all these things in on-click or short-cut key.由于我们的系统架构师,这是唯一的方法,我们可以通过 F5 按钮直接调试,但我想知道是否有解决方法,所以我可以通过单击或快捷键来完成所有这些事情。

Thank you very much.非常感谢。

http://blog.lavablast.com/post/2008/01/11/Attach-to-Process-with-one-shortcut.aspx http://blog.lavablast.com/post/2008/01/11/Attach-to-Process-with-one-shortcut.aspx

Create a macro in visual studio with the following:使用以下内容在 Visual Studio 中创建宏:

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal

Public Module RecordingModule
    Sub AttachToAspNET()
        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim compName As String = WindowsIdentity.GetCurrent().Name
            compName = compName.Substring(0, compName.IndexOf("\"))
            Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, compName).Item("w3wp.exe")
            proc2.Attach2(dbgeng)
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Module 

change w3wp.exe to aspnet if thats what you want.如果那是您想要的,请将 w3wp.exe 更改为 aspnet。 Then go into the key shortcuts and just bind a shortcut to run that macro.然后 go 进入快捷键并绑定一个快捷键来运行该宏。

Why don't you just go to project properties and select Use Local IIS Web Server.你为什么不只是 go 到项目属性和 select 使用本地 IIS ZC6E190B2854633C48EZ39E 服务器。

在此处输入图像描述

If this is remote server you can do this too: Using Visual Studio 2008 with IIS 7如果这是远程服务器,您也可以这样做: Using Visual Studio 2008 with IIS 7
Although the article is about VS2008, the concept is the same in 2010.虽然文章是关于 VS2008 的,但概念在 2010 年是一样的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自动附加到Visual Studio中的进程 - Automatically attach to process in Visual Studio 调试后自动杀死IIS Express进程(VS Express 2013 Web) - Automatically Kill IIS Express Process After Debugging (VS Express 2013 Web) 更快地附加到VS中的工作进程的方法 - Quicker way to attach to the worker process in VS 调试w / Attach to Process启动ASP.NET Dev Server - Debugging w/ Attach to Process Starts ASP.NET Dev Server 无法附加到 VS 2022 中的 w3wp 进程 - Cannot attach to w3wp process in VS 2022 Delphi 2007 for .NET中的“无法启动调试...无法附加到ASP.NET辅助进程”消息 - Incorrect “Unable to start debugging…Unable to attach to ASP.NET worker process” message in Delphi 2007 for .NET 如何将元素附加到另一个Ajax组件 - How to attach element to another Ajax component 如何自动附加到远程服务器上的特定IIS池? - How do you automatically attach to a specific IIS pool on remote server? 附加到进程不起作用 - Attach to process not working 尝试使用 Visual Studio 2008 附加到 ASP.NET 进程时,“Windows 64 位平台不支持混合模式调试” - “Mixed mode debugging is not supported on Windows 64-bit platforms” when trying to attach to an ASP.NET process using Visual Studio 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM