Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:03:14+00:00 2026-05-30T19:03:14+00:00

I am trying to trace a bug in our handling of com objects. Our

  • 0

I am trying to trace a bug in our handling of com objects. Our program is launched from our activeX control, and there is some com issue when the app is closed again. I would like to attach the visual studio (2008) debugger to our app when it is first launched from the OCX. How can I do that?

Some details:

a) OCX and app written primarily in c/c++ with just a little c++/cli (that play no role in the launching of the app)
b) If I attach to the program while it is running I get an assertion on exit in olelock.cpp

void AFXAPI AfxOleUnlockApp()  
{  
   AFX_MODULE_STATE* pModuleState = AfxGetModuleState();  
   ASSERT(pModuleState->m_nObjectCount != 0);  <--- Triggers this
   if (InterlockedDecrement(&pModuleState->m_nObjectCount) == 0)  
   {  
      // allow application to shut down when all the objects have  
      //  been released  
      ::AfxOleOnReleaseAllObjects();  
    }  
}

So I would like to attach the debugger to our program when it is first launched from the OCX so I can attempt to track the lifetime of the COM objects. Or perhaps there is another way to trace these objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:03:15+00:00Added an answer on May 30, 2026 at 7:03 pm

    gflags is what you would look into for complex scenarios in general. Specifically this page for debugging an app unconditionally when it is launched.

    However, I think this is overkill for what you want. I usually just dump some code in my program that will wait for a debugger to be attached if it was built in DEBUG mode and the F1 key is being pressed when the code starts up. Code like this shouldn’t get left in, but it’s pretty handy.

    #ifdef _DEBUG
    if ( ::GetAsyncKeyState( VK_F1 ) )
    {
        while ( !::IsDebuggerPresent() )
            ::Sleep( 100 );
        ::DebugBreak();
    }
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is this weird bug in my program that I'm trying to fix, but
I am trying to trace a deadlock that is occurring in our SQL 2005
I'm trying to track down an issue in our system and the following code
I'm trying to track down an issue in our MFC code that looks like
I'm trying to track down a bug with some random characters appearing when saving
Here is the stack trace which appears on resque-web interface: http://gist.github.com/396893 There you can
My team trying to trace a strange bug in a Rails (ver 2.3.8) application.
I'm in the process of trying to move our company from SalesForce to SugarCRM,
I'm trying to track down a bug that occurs when I click a particular
We are trying to trace the time a windows default printer was changed and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.