如何将 IE/FF 附加到 Visual Studio?
假设我有一个类库 cl1
和一个名为 clt1
的单元测试。我可以使用 Visual Studio 的“附加到进程”功能来附加到 NUnit 运行程序。这让我可以调试 cl1,例如设置断点。这是一个对于调试非常有用的功能。
我在 Visual Studio 和 IE/FF 中需要这种技术。假设我有一个使用 cl1
的 Web 应用程序。该应用程序通过 ASP.NET Web 开发服务器或 IIS 运行。我想在 cl1 中调试(设置断点)。我该怎么做?
请注意,这是不可能通过 Visual Studio 本身实现的。因为标记中的某些内容正在调用 cl1 类,并且我无法在 ASP.NET 标记中设置断点。我正在运行 Visual Studio 2010 Ultimate。
更新:
cl1
作为服务器端运行
Suppose I have a class library cl1
and a unit test for it that is called clt1
. I can use Visual Studio's Attach to Process feature to attach to NUnit runner. This lets me debug cl1
, for example set break points. It's a very helpful feature for debugging.
I'm in a need of this technique in Visual Studio and IE/FF. Suppose I have a web application that utilizes cl1
. This application is running via ASP.NET Web Development Server or IIS. I want to debug (set break points) in cl1
. How can I do this?
Please notice that it's not possible through Visual Studio itself. Because something in markup is calling cl1
classes and I can't set a break point in ASP.NET markup. I'm running Visual Studio 2010 Ultimate.
UPDATE:
cl1
is running as server side
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您的代码在服务器端运行,因此您需要附加调试器到服务器(IIS 或开发服务器,无论您正在运行哪个)。
我通常做的是设置断点,浏览到该站点(以确保该站点正在运行并且已“预热”),然后调试 -> Attach 并找到运行要附加的 Web 服务器的进程。然后,我浏览到将运行我的代码的位置并完成执行它的步骤。
如果 IIS 运行在不同的服务器上,您可以进行远程调试。
As your code is running server-side, you need to attach the debugger to the server (IIS, or dev server, whichever you are running).
What I normally do is set my breakpoint, browse to the site (in order to ensure that the site is running and has been "warmed up") then
Debug -> Attach
and find the process running the web server to attach to. I then browse to where my code will be run and go through the steps to execute it.If IIS is running on a different server, you can do remote debugging.
我猜您所指的类库包含 c#/vb.net 代码(服务器端),因此当代码由服务器执行时,您需要附加到网络服务器本身。如果网站托管在另一台计算机上,您可以使用 VS 远程调试器连接到 IIS。
I guess the class library you are referring to contains c#/vb.net code (server side) so as the code is executed by the server you will need to attach to the webserver itself. If the web site is hosted at another machine you can use VS remote debugger to attach to IIS.
您的库将在 ASP.Net 应用程序池内运行。在 IIS7 上,您应该附加到 w3wp.exe。旧版本的 IIS 可能会使用 aspnet_wp.exe。
Your library will be running inside the ASP.Net app pool. On IIS7 you should attach to w3wp.exe. Older versions of IIS may use aspnet_wp.exe instead.