From: Mammoth on
Hello
I got strange error when I try close my application.
Debug Assertion Failed....
in file.... cmdtarg.cpp line 43
Code in this file is:

#ifndef _AFX_NO_OLE_SUPPORT
if (m_xDispatch.m_vtbl != 0)
((COleDispatchImpl*)&m_xDispatch)->Disconnect();
ASSERT(m_dwRef <= 1); //line 43

What does it mean ?
Earlier all worked good...
I changed accidentally something in code or in controls and this error
doesn't allow me close the application.
I can't find mistake...

From: Doug Harrison [MVP] on
On 19 Apr 2007 15:39:39 -0700, Mammoth <cactusek(a)gmail.com> wrote:

>Hello
>I got strange error when I try close my application.
>Debug Assertion Failed....
>in file.... cmdtarg.cpp line 43
>Code in this file is:
>
>#ifndef _AFX_NO_OLE_SUPPORT
> if (m_xDispatch.m_vtbl != 0)
> ((COleDispatchImpl*)&m_xDispatch)->Disconnect();
> ASSERT(m_dwRef <= 1); //line 43
>
>What does it mean ?
>Earlier all worked good...
>I changed accidentally something in code or in controls and this error
>doesn't allow me close the application.
>I can't find mistake...

The m_dwRef member variable is a COM object reference count. Thus, the
assertion probably indicates that Release wasn't called as many times as
AddRef was called. This could occur if someone obtained an interface and
forgot to release it, or an exception was thrown between AddRef and Release
calls in exception-unsafe code, etc.

--
Doug Harrison
Visual C++ MVP
From: Mammoth on
What can I do and how find mistake?
I check interface and I don't see any oversightes.
Why error is only during closing application ?



>or an exception was thrown between AddRef and Release
calls in exception-unsafe code

could you say me how to avoid this ?

From: Doug Harrison [MVP] on
On 19 Apr 2007 16:02:00 -0700, Mammoth <cactusek(a)gmail.com> wrote:

>What can I do and how find mistake?

See if this article helps; I discovered it yesterday while researching
something else:

Did you know... How to Debug AddRef/Release Issues in Visual Studio?
http://blogs.msdn.com/saraford/archive/2005/05/03/414385.aspx

If all else fails, a brute force approach is to disable things until it no
longer fails and add stuff back until it does.

> I check interface and I don't see any oversightes.
>Why error is only during closing application ?

Because the assertion is in the CCmdTarget destructor, and the object,
whatever it is (you didn't say), is being destroyed at that time.

>>or an exception was thrown between AddRef and Release
>calls in exception-unsafe code
>
>could you say me how to avoid this ?

Typically you use smart pointers.

--
Doug Harrison
Visual C++ MVP
From: Mammoth on
I exchanged script.rc for older version this file and now is ok.
I don't know what was wrong.