堆中的错误C# [英] Heap error in C#
问题描述
TestKeyManagerApp.exe中的0x50f8fd85(msvcr90d.dll)中的未处理的异常:0xC0000005:访问冲突写入位置0x00000000。
调试模式中的最后一个位置:dbgheap.c(Visual studio 2008输出)
if(pHead == NULL)
{
* errno_tmp = ENOMEM; < ----- ACCESS VIOLATION
RTCCALLBACK(_RTC_FuncCheckSet_hook,(1));
}
我创建一个程序集类的对象一次(我的C#程序的私有成员),在构造函数中,我加载了本机的C ++ dll,现在如果我再次使用汇编对象(第二次调用一个测试函数)我收到了这个错误消息!
调用堆栈:
msvcr90d.dll!_heap_alloc_dbg_impl(unsigned int nSize = 532,int nBlockUse = 2,const char * szFileName = 0x50ec24a8 ,int nLine = 588,int * errno_tmp = 0x00000000)行431 + 0x3字节C ++
msvcr90d.dll!_nh_malloc_dbg_impl(unsigned int nSize = 532,int nhFlag = 0,int nBlockUse = 2,const char * szFileName = 0x50ec24a8,int nLine = 588,int * errno_tmp = 0x00000000)行239 + 0x19字节C ++
msvcr90d.dll!_calloc_dbg_impl(unsigned int nNum = 1,unsigned int nSize = 532,int nBlockUse = 2,const char * szFileName = 0x50ec24a8,int nLine = 588,int * errno_tmp = 0x00000000)行593 + 0x20字节C ++
msvcr90d.dll!_getptd_noexit()行588 + 0x1a字节C
msvcr90d.dll!_errno()行281 + 0x5字节C
msvcr90d.dll!_calloc_dbg(unsigned int nNum = 1,unsigned int nSize = 532,int nBlockUse = 2,const char * szFileName = 0x50ec20a4,int nLine = 373)行646 + 0x11 bytes C ++
msvcr90d.dll!__ CRTDLL_INIT(void * hDllHandle = 0x50ec0000,unsigned long dwReason = 2,void * lpreserved = 0x00000000)行373 + 0x18 bytes C
msvcr90d.dll!_CRTDLL_INIT(void * hDllHandle = 0x50ec0000,unsigned long dwReason = 2,void * lpreserved = 0x00000000)行214 + 0x11 bytes C
ntdll.dll!77c68968()
[下面的框可能不正确和/或丢失,没有加载ntdll.dll的符号]
ntdll.dll!77c73820()
ntdll.dll!77c735bc()
我希望你有提示或提示? >
Thx!
检查调用堆栈,特别是非托管堆栈。为此,您必须启用非托管代码调试。
这可能是伪造的删除或者danging /无效的指针访问。通过最小化本机DLL调用来缩小问题。
I have a C# program to test a C++/CLI assembly (this assembly is a wrapper to a native C++ dll) and I'm getting following error message:
Unhandled exception at 0x50f8fd85 (msvcr90d.dll) in TestKeyManagerApp.exe: 0xC0000005: Access violation writing location 0x00000000.
last position in debug mode: dbgheap.c (Visual studio 2008 output)
if (pHead == NULL)
{
*errno_tmp = ENOMEM; <----- ACCESS VIOLATION
RTCCALLBACK(_RTC_FuncCheckSet_hook,(1));
}
I create an object of the assembly class once (private member of my C# program), in constructor I load the native C++ dll and now if I use the assembly object second time (second call of a testfunction) I got this error messages!
output of Call Stack:
msvcr90d.dll!_heap_alloc_dbg_impl(unsigned int nSize=532, int nBlockUse=2, const char * szFileName=0x50ec24a8, int nLine=588, int * errno_tmp=0x00000000) Line 431 + 0x3 bytes C++
msvcr90d.dll!_nh_malloc_dbg_impl(unsigned int nSize=532, int nhFlag=0, int nBlockUse=2, const char * szFileName=0x50ec24a8, int nLine=588, int * errno_tmp=0x00000000) Line 239 + 0x19 bytes C++
msvcr90d.dll!_calloc_dbg_impl(unsigned int nNum=1, unsigned int nSize=532, int nBlockUse=2, const char * szFileName=0x50ec24a8, int nLine=588, int * errno_tmp=0x00000000) Line 593 + 0x20 bytes C++
msvcr90d.dll!_getptd_noexit() Line 588 + 0x1a bytes C
msvcr90d.dll!_errno() Line 281 + 0x5 bytes C
msvcr90d.dll!_calloc_dbg(unsigned int nNum=1, unsigned int nSize=532, int nBlockUse=2, const char * szFileName=0x50ec20a4, int nLine=373) Line 646 + 0x11 bytes C++
msvcr90d.dll!__CRTDLL_INIT(void * hDllHandle=0x50ec0000, unsigned long dwReason=2, void * lpreserved=0x00000000) Line 373 + 0x18 bytes C
msvcr90d.dll!_CRTDLL_INIT(void * hDllHandle=0x50ec0000, unsigned long dwReason=2, void * lpreserved=0x00000000) Line 214 + 0x11 bytes C
ntdll.dll!77c68968()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!77c73820()
ntdll.dll!77c735bc()
I hope you will have hints or tips for me?
Thx!
Check the call stack, specially the unmanaged one. For this you must enable Unmanaged-code Debugging. This is probably bogus delete or danging/invalid pointer access. Narrow down the problem by minimizing the native DLL call.
这篇关于堆中的错误C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!