Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Debug Assertion Failed...

Debug Assertion Failed...

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestioncsharpsharepoint
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RYU
    wrote on last edited by
    #1

    Hi, I have an ActiveX component that I build using MFC. I use this component in my C# application. Every time I close my C# application, it generated this error:

    Debug Assertion Failed!
    Program: ...
    File: f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp
    Line: 1007
    etc..
    etc..
    etc..

    I do the debugging and it fails on this line:

    #ifdef _DEBUG
    ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
    #endif

    I know it is not an important question, because if it is in release, it works perfectly. But I was wondering, what can cause this problem? Please note: 1. This error only occurs on my specific application. 2. When I build a new C# application. It works fine. Any idea?

    R 1 Reply Last reply
    0
    • R RYU

      Hi, I have an ActiveX component that I build using MFC. I use this component in my C# application. Every time I close my C# application, it generated this error:

      Debug Assertion Failed!
      Program: ...
      File: f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp
      Line: 1007
      etc..
      etc..
      etc..

      I do the debugging and it fails on this line:

      #ifdef _DEBUG
      ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
      #endif

      I know it is not an important question, because if it is in release, it works perfectly. But I was wondering, what can cause this problem? Please note: 1. This error only occurs on my specific application. 2. When I build a new C# application. It works fine. Any idea?

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      RYU^^ wrote:

      I know it is not an important question, because if it is in release, it works perfectly.

      Probably not. The ASSERT macro is disabled when you're building for release, which means that the problem is only disguised in release mode. If you have a look at the surrounding comments in the wincore.cpp file, you'll find that this assertion is due to that the window handle has not been detached from the object handle map. When you use wizards to generate code for your application, as I assume you have, this assertion won't be triggered by the generated code. My point is that this is something else and I would bet my money on COM-related stuff. If you put some breakpoints to check which window it is that's causing problems, I would expect it to be an unknown window from your point of view. Some things to check up on:

      • Make sure that you release all interface references to your ActiveX when the application is closed.
      • Make sure you calling ::CoUninitialize() for each time you've called ::CoInitialize() or similar.
      • If you're using a secondary thread that operates on the ActiveX, you have to set up the COM library for that thread as well by calling ::CoInitialize() / ::CoUninitialize(). Remember that you also have to marshal the interfaces to the secondary thread.

      You may find this article[^] to be interesting as well.

      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      R 1 Reply Last reply
      0
      • R Roger Stoltz

        RYU^^ wrote:

        I know it is not an important question, because if it is in release, it works perfectly.

        Probably not. The ASSERT macro is disabled when you're building for release, which means that the problem is only disguised in release mode. If you have a look at the surrounding comments in the wincore.cpp file, you'll find that this assertion is due to that the window handle has not been detached from the object handle map. When you use wizards to generate code for your application, as I assume you have, this assertion won't be triggered by the generated code. My point is that this is something else and I would bet my money on COM-related stuff. If you put some breakpoints to check which window it is that's causing problems, I would expect it to be an unknown window from your point of view. Some things to check up on:

        • Make sure that you release all interface references to your ActiveX when the application is closed.
        • Make sure you calling ::CoUninitialize() for each time you've called ::CoInitialize() or similar.
        • If you're using a secondary thread that operates on the ActiveX, you have to set up the COM library for that thread as well by calling ::CoInitialize() / ::CoUninitialize(). Remember that you also have to marshal the interfaces to the secondary thread.

        You may find this article[^] to be interesting as well.

        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
        "High speed never compensates for wrong direction!" - unknown

        R Offline
        R Offline
        RYU
        wrote on last edited by
        #3

        Hi Roger, I can call Dispose(). I think that is similar with ::CoUninitialize(); but where can I put that function? There is no Disposing event in the user control. I tried to put in Disposed event, but it still doesn't work :( Any idea? Thanks for your help again... :)

        R 1 Reply Last reply
        0
        • R RYU

          Hi Roger, I can call Dispose(). I think that is similar with ::CoUninitialize(); but where can I put that function? There is no Disposing event in the user control. I tried to put in Disposed event, but it still doesn't work :( Any idea? Thanks for your help again... :)

          R Offline
          R Offline
          Roger Stoltz
          wrote on last edited by
          #4

          What is Dispose() and what does it do? Do you have a link to it in MSDN? I think Dispose() may be C# specific, so perhaps you should ask in that forum instead to get better suited answers.

          "It's supposed to be hard, otherwise anybody could do it!" - selfquote
          "High speed never compensates for wrong direction!" - unknown

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups