Link to home
Start Free TrialLog in
Avatar of skirmish76
skirmish76

asked on

Simple Unsolvable Problem - mtex.cpp(90)

I am working on a very large application that uses CMutex and CSingleLock for synchronisation.  I am told that this code worked perfectly under VC++ 6 but since rolling over to .NET (2003) there are problems.

The program will go down because of an ASSERT in line 90 of mtex.cpp (one of the afx files I think).  I've located this file and here is the relavent code:

CSingleLock::CSingleLock(CSyncObject* pObject, BOOL bInitialLock)
{
      ASSERT(pObject != NULL);
      ASSERT(pObject->IsKindOf(RUNTIME_CLASS(CSyncObject)));  //FAILS HERE
....

When this fires it appears that pObject passed to it appears to be a valid pointer to an object of type Win32ThreadResource which is one of our classes that inherits from CMutex (and doesn't appear to be more then a wrapper).

Anyway this code has worked for a very long time but under VS .NET it fires the above assert (then dies).  Any ideas?

Adam
Avatar of nonubik
nonubik

Does your Win32ThreadResource class implements dynamicaly the CMutex MFC class?

You need to have :

/* Win32ThreadResource .h */
class Win32ThreadResource : public CMutex
{
     int num;
public:
     DECLARE_DYNAMIC(Win32ThreadResource )
};

//==============
/* Win32ThreadResource .cpp */
#include "stdafx.h"
#include "Win32ThreadResource .h"

IMPLEMENT_DYNAMIC(Win32ThreadResource , CMutex )

Avatar of skirmish76

ASKER

I added the DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC macros as you suggested but the problems remains.  Thanks for suggesting them though, I read the doco for them and they really did sound like they would solve the problem (seeing as the problem was an assertion failure of KindOf() ).

If you have any more ideas please post them.  This problem continues to be extremely frustrating.
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial