在视觉c中实现bonjour sdk++ Windows 窗体应用程序
我已经在 Visual C++ 控制台应用程序中成功实现了 bonjour sdk。但是当我尝试在 Windows 窗体应用程序(Visual C++)中实现相同的代码时,我收到奇怪的错误,可能与 bonjour dll 的某些本地堆问题有关。
文件 dbgheap.c 中的以下断言失败:
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
如果有人知道处理此类问题的一些资源,那将非常有帮助。
非常感谢您的帮助
I have succesfully implemented the bonjour sdk in a visual c++ console app. but when I am trying to implement the same code in a windows forms app (visual c++) I am receiving weird errors probably related to some local heap problem with the bonjour dll.
The following assertion in the file dbgheap.c fails:
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
It would be really helpful if someone knew some resources dealing with this kind of problem.
Thanks a lot for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有向我们提供太多信息,但可以从以下地方开始查找:
您是否正在释放 Bonjour 分配的对象? bonjour.dll 链接到哪个 C 运行时库?您是否在表单应用程序中使用相同的应用程序(DLL 或静态、多线程或非多线程、调试或发布)?您使用的控制台应用程序是否与控制台应用程序中的相同?
一般来说,出于这种原因释放在其他 dll 中分配的内存是一个坏主意。是否没有可以调用的
BonjourFree
函数来释放 Bonjour 中分配的对象?或者,您可能会超出缓冲区并独立地覆盖 Bonjour 上的调试内存分配边界。尝试查看失败空闲处的内存,看看它是否正确。
You haven't provided us with very much information, but one place to start looking is this bit:
Are you freeing objects allocated by Bonjour? Which C runtime library is bonjour.dll linked against? Are you using the same one (DLL or static, multithreaded or not, debug or release) in your forms app? Are you using the same one as in your console app?
In general it's a bad idea to free memory allocated in other dlls for this sort of reason. Isn't there a
BonjourFree
function you can call to deallocate objects allocated in Bonjour?Alternatively you may be overrunning a buffer and overwriting the debug memory allocation boundaries indepdently on Bonjour. Try looking at the memory at the failing free and see if it looks correct.