调试类库
我有从经典 ASP 调用的 ac# 类库。
是否可以使用 Visual Studio 进行调试?课堂上的断点不起作用,这并不奇怪。
我在 iis7 的浏览器中运行它,而不是通过 Visual Studio 2010,因为我使用的是经典的 ASP 页面。我是否需要在 Visual Studio 中运行它才能正常工作?
我也尝试使用 Response.writes,但结果是: 当前上下文中不存在名称“Response”
I have a c# class library that I am calling from Classic ASP.
Is it possible to debug this using visual studio? Break points in the class don't work, which isn't surprising.
I am running this on iis7 in the browser, rather than through Visual Studio 2010 because of the fact that I'm using a classic ASP page. Do I need to get this running in Visual Studio in order for this to work?
I also tried to use Response.writes, but they result in:
The name 'Response' does not exist in the current context
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您需要将调试器附加到加载程序集的进程(IIS 或用于调试经典 ASP 应用程序的另一个调试器)。
在 VS2010 下,转到“工具”->“附加到进程(2008 年也可能相同)。
You need to attach the debugger to the process (either IIS or another debugger that you are using to debug your classic ASP application) that is loading the assembly.
Under VS2010 go to Tools -> Attach to Process (probably the same under 2008 as well).
尝试添加库的代码:
System.Diagnostics。 Debugger.Break();
你想要中断的地方。还要确保使用 pdb 符号编译和部署 lib。当代码到达该指令时,IIS 将抛出异常。系统会要求您附加调试器,然后您就可以了。try to add in the code of the lib:
System.Diagnostics.Debugger.Break();
where you want to break. Also ensure the lib is compiled and deployed with the pdb symbols. When the code will reach the instruction, IIS will throw an exception. The system will ask you to attach a debugger, and you're on the way.我实际上写了一篇关于此的文章:
http://www.jameswiseman.com /blog/tag/visual-studio-2010/
摘自文章:
打开 Visual Studio 2010
如果您安装了它,这很容易。如果您不这样做,可能会有点棘手;-)
在 Visual Studio 中打开您的网站
再次,足够简单。
启动您的网站。
即打开浏览器并导航到网站。
在 Visual Studio 中,单击“调试”菜单 -> “附加到进程”
“Inetinfo.exe”;如果应用程序保护较高,则可能需要勾选“dllhost.exe”。您可能会看到“附加安全警告”弹出窗口。如果是这样,请继续。一开始有点害怕,但如果它是您自己 PC 上的应用程序,那就没问题了。
如果您对此感到担心,请遵循 MSDN 上的建议.
向您的代码添加一个断点,然后导航到您将遇到该断点的位置。
疑难解答 - 注册 pdm.dll
我第一次尝试时就成功了。后来的尝试并不是那么成功,我发现了一些不得不做的事情。
当尝试附加到“脚本代码”时,我在 IDE 中收到以下警告。
只需按照这些说明操作即可。
疑难解答 - 重新启动 IIS
这曾经也有帮助。实在说不出为什么。
I actually wrote an article regarding this:
http://www.jameswiseman.com/blog/tag/visual-studio-2010/
From the article:
Open Visual Studio 2010
This is easy enough if you have it installed. Might be a bit tricky if you don’t ;-)
Open your website in Visual Studio
Again, easy enough.
Fire up your web site.
I.e. open your browser and navigate to the website.
In Visual Studio, click ‘Debug’ Menu -> ‘Attach to process’
‘Inetinfo.exe‘ if application protection is low or ”dllhost.exe‘ if application protection is higher. You may get an ‘Attach Security Warning’ popup. If so, continue On. It’s a bit scary at first, but if it’s your own app on your own PC, then you’ll be ok.
If you’re worried about this, follow the advice on MSDN.
Add a breakpoint to your code, and navigate to a location where you will hit it.
Troubleshooting - Registering pdm.dll
This worked on the first occasion that I tried it. Subsequent attempts were not so successful, and I found a few things that I had to do.
When trying to attach to ‘Script Code’ I got the following warning in the IDE.
Just follow these instructions.
Troubleshooting - Restart IIS
This also helped on one occasion. Can’t really say why.
如果您将 .net 类包装在 Web 服务中,然后从经典的 ASP 页面调用该 Web 服务,您的生活将会变得更加轻松。
You will make your life much easier all round if you wrap you .net classes in a web service then call the web service from the classic asp pages.
对于调试,请将调试器附加到进程,如其他答案中所述。
对于跟踪,我发现类库中的
System.Diagnostics.Trace.Writeline()
与OutputDebugString侦听器(如调试视图。For debugging, attach the debugger to the process as described in other answers.
For tracing, I find very handy the combination between
System.Diagnostics.Trace.Writeline()
in the class library and an OutputDebugString listener like DebugView.