ATL problem

M

Maxim

Hi all,

I'm trying to use ATL (CString, CCOMSafeArray, etc.) classes in managed C++
code, but I get the following assert exeption when I start the application:

Debug Assertion Failed:

Expression: _CrtIsValidHeapPointer(pUserData)

in file 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've found that this problems appears when I use ATL classes. Without them
the code works fine.

Can anybody help me with this?

Thanks in advance
 
W

William DePalo [MVP VC++]

Maxim said:
I'm trying to use ATL (CString, CCOMSafeArray, etc.) classes in managed
C++

Managed Extensions for C++ in VS2003 and not the managed version of C++ in
VS2005 called C++/CLI?
code, but I get the following assert exeption when I start the
application:

Debug Assertion Failed:

Expression: _CrtIsValidHeapPointer(pUserData)

in file dbgheap.c

If you are using VS2003 it is most likely the mixed-mode / loader-lock
issue. See here:

http://support.microsoft.com/?id=814472

http://msdn.microsoft.com/msdnmag/issues/06/06/CAtWork/

If it is 2005 that you are using, please say so. Someone will probably offer
another solution.

Regards,
Will
www.ivrforbeginners.com
 
M

Maxim

Thanks for reply, William.

Sorry I'm new to all this managed stuff. I'm using VC2005. So it would be
C++/CLI.
 
W

William DePalo [MVP VC++]

Maxim said:
Thanks for reply, William.

You are welcome.
Sorry I'm new to all this managed stuff.

No need to be sorry.
I'm using VC2005. So it would be C++/CLI.

Then I'm sorry to say I don't know what the problem is. In the second link I
posted, the author reported a similar assertion in code he wrote. He said
his problem was that he mistakenly linked with the /NOENTRY switch. You
didn't do that, did you?

Regards,
Will
www.ivrforbeginners.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top