简体   繁体   English

Visual Studio调试引用的DLL

[英]Visual Studio Debugging Referenced DLL

I have an ASP.NET web site which uses a compiled DLL from another Visual Studio solution (have the DLL's original solution -- .cs files, .csproj , .sln , etc.) as a reference. 我有一个ASP.NET网站,该网站使用另一个Visual Studio解决方案(具有DLL的原始解决方案.cs文件, .csproj.sln等)的已编译DLL作为参考。

There's an exception coming up to the web site from this DLL, and I'd like to debug it (the DLL). 从此DLL到网站的异常,我想对其进行调试(DLL)。 Can I do this? 我可以这样做吗? Can I drill down into the DLL, set break points, etc. somehow? 我可以以某种方式深入到DLL,设置断点等吗? I've heard of "attaching the debugger", but I have never done that, and certainly not with a DLL. 我听说过“附加调试器”,但是我从未这样做过,当然也没有使用DLL。 What are the steps to do this? 有哪些步骤可以做到这一点?

Stack Overflow question Debugging a third-party DLL in Visual Studio.NET? 堆栈溢出问题在Visual Studio.NET中调试第三方DLL? is asking the same thing. 在问同样的事情。 The answer for it is basically to use .NET Reflector to decompile the DLL and look a the code. 基本上,答案是使用.NET Reflector反编译DLL并查看代码。

However, if you have the solution, and all source code, for the DLL then you could change the reference to point to the other project instead of the DLL. 但是,如果您具有DLL的解决方案和所有源代码,则可以更改引用以指向另一个项目而不是DLL。 Then you can step into the functions as you would any other in the code. 然后,您可以像执行代码中的任何其他步骤一样进入这些函数。

Another way, again if you have the code, is to run the application and attach to the process. 同样,如果您有代码,另一种方法是运行应用程序并附加到流程。 To do this, you would open the other solution in Visual Studio, and attach the debugger to the ASP.NET worker process ( aspnet_wp or something like that if I recall correctly). 为此,您将在Visual Studio中打开另一个解决方案,并将调试器附加到ASP.NET辅助进程( aspnet_wp或类似的东西,如果我没记错的话)。 This will allow you to set breakpoints and have them be hit when you go to the right parts of your website. 这将使您可以设置断点,并在您访问网站的正确部分时被命中。 It would be the ASP worker process i you are browsing to the site in Internet Explorer on your local IIS for example. 例如,如果您要浏览到本地IIS上Internet Explorer中的站点,那将是ASP工作进程。 If you are running it in Visual Studio then it is likely to be using the built-in web browser. 如果您在Visual Studio中运行它,则可能正在使用内置的Web浏览器。 So you would need to attach to that. 因此,您需要附加该内容。

There might be a way to do it if you have the pdb files for the DLL as well, but I have never really tried to do that. 如果您也有用于DLL的pdb文件,则可能有一种方法可以执行此操作,但我从未真正尝试过这样做。 I know that if you have the pdb files then you can get the source back when using tools like WinDbg to debug. 我知道,如果您拥有pdb文件,则可以使用WinDbg之类的工具进行调试时找回源代码。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM