[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 629
  • Last Modified:

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
0
skirmish76
Asked:
skirmish76
  • 2
1 Solution
 
nonubikCommented:
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 )

0
 
skirmish76Author Commented:
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.
0
 
nonubikCommented:
How is the Win32ThreadResource class declared?
I made a class derived from CMutex and built a CSingleLock with such an object and worked fine.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now