简体   繁体   English

在VS2010中调试COM dll

[英]Debug COM dll in VS2010

I have an ASP.NET WebApplication (.NET 4.0/C#) that works with an external COM dll (written in C++). 我有一个ASP.NET WebApplication(.NET 4.0 / C#),它与外部COM dll(用C ++编写)一起工作。

On a function call, which worked perfectly with an older ASP project, I get a AccessViolationException in the DLL code. 在函数调用上,它与旧的ASP项目完美配合,我在DLL代码中得到了一个AccessViolationException。

To debug it, I requested a debug version of the DLL from my colleague who wrote it. 为了调试它,我从我的同事那里请求了DLL的调试版本。 I have no access to the dll project or source code directly though. 我无法直接访问dll项目或源代码。

How can I use this debug dll to find out where the error is occuring? 如何使用此调试DLL来找出错误发生的位置? 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. 编辑:我也有.pdb文件,如果这是好的。 For some reason I cannot see the COM dll in the Debug->Windows->Modules overview. 出于某种原因,我无法在Debug-> Windows-> Modules概述中看到COM dll。 I'm really stuck, any help appreciated. 我真的被卡住了,任何帮助都很感激。

You need to have Unmanaged Code Debugging enabled. 您需要启用非托管代码调试

From MSDN : 来自MSDN

The Unmanaged code debugging property, available on the Debug page of the Project Designer, determines whether debugging of native code is supported. Project Designer的Debug页面上提供的Unmanaged code debugging属性确定是否支持调试本机代码。 Select this option if you are making calls to COM objects, or if you start a custom program written in native code that calls your project and you need to debug the native code. 如果要调用COM对象,或者如果启动用调用项目的本机代码编写的自定义程序,并且需要调试本机代码,请选择此选项。

For ASP, you need to check 'Native Code' in the Debuggers section of the Web tab. 对于ASP,您需要在Web选项卡的Debuggers部分中检查'Native Code'。

Also you should have Just My Code debugging disabled in the debugging options. 此外,您应该在调试选项中禁用“我的代码”调试

Perhaps you could use Ildasm.exe to rip through the dll to see what you are missing. 也许您可以使用Ildasm.exe来翻录dll以查看您缺少的内容。 As for violations it sounds as if it is similar to this issue. 至于违规行为,听起来好像与此问题类似。 Try a static import from this SO. 尝试从此SO进行静态导入。 MsCorlib.dll may be having an issue with the third party dll. MsCorlib.dll可能与第三方DLL有问题。

Unmanaged DLL causing AccessViolationException 非托管DLL导致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. 我建议在控制台应用程序中使用DllImport来查看它是否可以解析。 Best of lucK! 最好的lucK!

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

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