visual-studio 使用 Visual Studio 2008 远程调试 Web 应用程序的服务器端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:25:52  来源:igfitidea点击:

Remote Debugging Server Side of a Web Application with Visual Studio 2008

asp.netvisual-studiodebuggingasp-classic

提问by Bert Lamb

So, I've read that it is not a good idea to install VS2008 on my test server machine as it changes the run time environment too much. I've never attempted remote debugging with Visual Studio before, so what is the "best" way to get line by line remote debugging of server side web app code. I'd like to be able to set a breakpoint, attach, and start stepping line by line to verify code flow and, you know, debug and stuff :).

所以,我读到在我的测试服务器机器上安装 VS2008 不是一个好主意,因为它改变了太多的运行时环境。我以前从未尝试过使用 Visual Studio 进行远程调试,那么逐行远程调试服务器端 Web 应用程序代码的“最佳”方法是什么。我希望能够设置断点、附加并开始逐行执行以验证代码流,以及调试和其他内容:)。

I'm sure most of the answers will pertain to ASP.NET code, and I'm interested in that, but my current code base is actually Classic ASP and ISAPI Extensions, so I care about that a little more.

我确信大多数答案都与 ASP.NET 代码有关,我对此很感兴趣,但我当前的代码库实际上是经典 ASP 和 ISAPI 扩展,所以我更关心这一点。

Also, my test server is running in VMWare, I've noticed in the latest VMWare install it mentioning something about debugging support, but I'm unfamiliar with what that means...anyone using it, what does it do for you?

另外,我的测试服务器在 VMWare 中运行,我注意到在最新的 VMWare 安装中它提到了有关调试支持的内容,但我不熟悉这意味着什么......任何使用它的人,它对你有什么作用?

回答by Paul Mrozowski

First, this is MUCH easier if both the server and your workstation are on the same domain (the server needs access to connect to your machine). In your C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86 (or x64, or ia64) directory are the files you need to copy to your server. There are different versions between Visual Studio versions, so make sure they match on the client and server side. On the server, fire up msvsmon. It will say something like "Msvsmon started a new server named xxx@yyyy". This is the name you'll use in Visual Studio to connect to this server. You can go into Tools > Options to set the server name and to set the authentication mode (hopefully Windows Authentication) - BTW No Authentication doesn't work for managed code.

首先,如果服务器和您的工作站都在同一个域中(服务器需要访问连接到您的机器),这会容易得多。在您的 C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86(或 x64,或 ia64)目录中是您需要复制到服务器的文件。Visual Studio 版本之间存在不同的版本,因此请确保它们在客户端和服务器端匹配。在服务器上,启动 msvsmon。它会说“Msvsmon 启动了一个名为 xxx@yyyy 的新服务器”。这是您将在 Visual Studio 中用于连接到此服务器的名称。您可以进入工具 > 选项来设置服务器名称并设置身份验证模式(希望是 Windows 身份验证) - 顺便说一句,无身份验证不适用于托管代码。

On the client side, open up Visual Studio and load the solution you're going to debug. Then go to Debug > Attach to Process. In the "Qualifier" field enter the name of the server as you saw it appear earlier. Click on the Select button and select the type of code you want to debug, then hit OK. Hopefully you'll see a list of the processes on the server that you can attach to (you should also see on the server that the debugging monitor just said you connected). Find the process to attach to (start up the app if necessary). If it's an ASP.NET website, you'd select w3wp.exe, then hit Attach. Set your breakpoints and hopefully you're now remotely debugging the code.

在客户端,打开 Visual Studio 并加载您要调试的解决方案。然后去调试>附加到进程。在“限定符”字段中输入您之前看到的服务器名称。单击“选择”按钮并选择要调试的代码类型,然后单击“确定”。希望您会看到服务器上可以附加到的进程列表(您还应该在服务器上看到调试监视器刚刚说您已连接)。找到要附加到的进程(如有必要,启动应用程序)。如果是 ASP.NET 网站,则选择 w3wp.exe,然后点击附加。设置断点,希望您现在可以远程调试代码。

AFAIK - the VMWare option lets you start up code inside of a VM but debug it from your workstation.

AFAIK - VMWare 选项允许您在 VM 内启动代码,但可以从您的工作站对其进行调试。

回答by Craig.Nicol

Visual Studio comes with a remote debuggerthat you can run as an exe on your server. It works best if you can run it as the same domain user as your copy of visual studio. You can then do an attach to process from the debugger on your machine to the IIS process on the server and debug as if it was running on your machine. You get more options for .Net debugging, but there's support for older platforms too.

Visual Studio 附带一个远程调试器,您可以在服务器上将其作为 exe 运行。如果您可以以与您的 Visual Studio 副本相同的域用户身份运行它,则效果最佳。然后,您可以将机器上的调试器的进程附加到服务器上的 IIS 进程,并像在您的机器上运行一样进行调试。您可以获得更多的 .Net 调试选项,但也支持旧平台。