在Windows CE的托管C#代码中将本机DLL加载为调试模块
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在Windows CE的托管C#代码中将本机DLL加载为调试模块,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1821字,纯文字阅读大概需要3分钟。
内容图文
我正在使用以下方法在C#中编写一个引用本机C DLL(我也在编码)的Windows CE应用程序:
[DllImport("CImg_IP_CE.dll")]
public static unsafe extern void doBlur(byte* imgData, int sigma);
这实际上工作正常,但我无法调试DLL.当我检查运行EXE后加载的调试模块时,CImg_IP_CE.dll不是其中之一.即使从DLL成功调用函数后,它仍然不会出现在模块列表中.
环顾四周后,似乎LoadLibrary()函数可能会起作用,但是我找不到在C#Windows CE应用程序中使用此功能的任何示例.我该怎么做,或者有更好的方法来确保DLL加载进行调试?
解决方法:
我通过这篇文章找到了答案:
http://www.eggheadcafe.com/conversation.aspx?messageid=31762078&threadid=31762074
总之,有人问了同样的问题,回答是:
No, you can’t step from managed code through a P/Invoke call into native
code in the Smart Device debugger. You might be able to use Attach to
Process to do the native debugging (with the native DLL project loaded into
that instance of VS2005), or simply write debug information from the native
DLL to a serial port or something. This really doesn’t come up very often,
though, where you actually need to step from one to the other.
在线程的更远处,有人想出了如何做到这一点:
A quick test shows that the easiest way to handle this is to ‘run’ your DLL.
That is, set the debugging options to start the managed code EXE that will
use your DLL and set your breakpoints in the DLL (all from the DLL project,
of course). Naturally, when the EXE starts, your DLL won’t be loaded, so
you’ll see the breakpoints as hollow circles with ! on them, but, when you
call any of the native functions in your DLL, the DLL will be loaded (it’s
not loaded on startup), and the breakpoints will be set.
奇怪的是,当您运行C#程序并调用本机DLL代码时,它仍未在调试模块窗口中显示为已加载.但是,如果将DLL项目设置为启动项目,然后在“调试”选项中将“远程可执行文件”设置为EXE文件,则当您首次调用DLL时,它将在调试器中加载.好吧…无论如何!
内容总结
以上是互联网集市为您收集整理的在Windows CE的托管C#代码中将本机DLL加载为调试模块全部内容,希望文章能够帮你解决在Windows CE的托管C#代码中将本机DLL加载为调试模块所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。