在VS2010中调试COM dll
我有一个 ASP.NET WebApplication (.NET 4.0/C#),它与外部 COM dll(用 C++ 编写)配合使用。
在一个与旧的 ASP 项目完美配合的函数调用中,我在 DLL 代码中收到 AccessViolationException。
为了调试它,我向编写该 DLL 的同事请求了该 DLL 的调试版本。但我无法直接访问 dll 项目或源代码。
如何使用这个调试dll来找出错误发生的位置?我找不到进入我正在调用的方法的方法。是否可以?
编辑:我也有 .pdb 文件,如果有的话。由于某种原因,我在“调试”->“Windows”->“模块”概述中看不到 COM dll。我真的很困惑,非常感谢任何帮助。
I have an ASP.NET WebApplication (.NET 4.0/C#) that works with an external COM dll (written in C++).
On a function call, which worked perfectly with an older ASP project, I get a AccessViolationException in the DLL code.
To debug it, I requested a debug version of the DLL from my colleague who wrote it. I have no access to the dll project or source code directly though.
How can I use this debug dll to find out where the error is occuring? I could not find a way to step into the method I am calling. Is it possible?
EDIT: I have the .pdb file as well, if that's any good. For some reason I cannot see the COM dll in the Debug->Windows->Modules overview. I'm really stuck, any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要启用非托管代码调试。
来自 MSDN:
对于 ASP,您需要在 Web 选项卡的“调试器”部分中选中“本机代码”。
此外,您还应该在调试选项中禁用仅我的代码调试。
You need to have Unmanaged Code Debugging enabled.
From MSDN:
For ASP, you need to check 'Native Code' in the Debuggers section of the Web tab.
Also you should have Just My Code debugging disabled in the debugging options.
也许您可以使用 Ildasm.exe 来破解 dll 以查看丢失的内容。至于违规问题,听起来似乎与这个问题类似。尝试从此 SO 进行静态导入。 MsCorlib.dll 可能与第三方 dll 存在问题。
非托管 DLL 导致 AccessViolationException
请注意依赖关系,并且您可能会遇到一些封送问题。我建议在控制台应用程序中使用 DllImport 来查看它是否可以解决。祝你好运!
Perhaps you could use Ildasm.exe to rip through the dll to see what you are missing. As for violations it sounds as if it is similar to this issue. Try a static import from this SO. MsCorlib.dll may be having an issue with the third party dll.
Unmanaged DLL causing AccessViolationException
Be aware of the dependencies and that you may have some marshaling issues. I advise using DllImport in a console app to see if it can resolve. Best of lucK!