Exception 0xC0000008 in NTDLL.DLL

I was trying following solution posted on site

http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_10117764.html?query=first+handle+0xc0000008&clearTAFilter=true#1182280

//Code is
      __try
      {
      // TODO: Add your control notification handler code here
      short ret;
      _clsACD WinDLL;
      EnableWindow(FALSE);
      WinDLL.CreateDispatch("WinDLL.clsACD");
      ret = WinDLL.GetCassStatus();
      }
      __except(EXCEPTION_CONTINUE_EXECUTION){
            puts ( "We knew that this would go wrong...");
      }
               EnableWindow(TRUE);


but am getting following errors.


C:\Projects\WinDemo\VC6WinDemoVB6\WinDemoDlg.cpp(269) : error C2712: Cannot use __try in functions that require object unwinding

What do U suggest should I do?

James_ClementsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
>>What do U suggest should I do?

Don't use objct instnces here, use pointers, e.g.

short TestWithSEH(_clsACD* pWinDLL)
{
     short ret;

     __try
     {
     // TODO: Add your control notification handler code here


     EnableWindow(FALSE);
     pWinDLL->CreateDispatch("WinDLL.clsACD");
     ret = pWinDLL->GetCassStatus();
     }
     __except(EXCEPTION_CONTINUE_EXECUTION){
          puts ( "We knew that this would go wrong...");
     }

    return ret;
}

And call it like

    _clsACD WinDLL;
    TestWithSEH(&WinDLL);
jkrCommented:
Sorry, make that

short TestWithSEH(_clsACD* pWinDLL)
{
     short ret;

     __try
     {
     // TODO: Add your control notification handler code here


     pWinDLL->CreateDispatch("WinDLL.clsACD");
     ret = pWinDLL->GetCassStatus();
     }
     __except(EXCEPTION_CONTINUE_EXECUTION){
          puts ( "We knew that this would go wrong...");
     }

    return ret;
}

and

    EnableWindow(FALSE);
    _clsACD WinDLL;
    short ret = TestWithSEH(&WinDLL);
    EnableWindow(TRUE);
jkrCommented:
BTW, that exception in question is

#define STATUS_INVALID_HANDLE            ((NTSTATUS)0xC0000008L)
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

James_ClementsAuthor Commented:
Now I am getting error below

 error C2373: 'TestWithSEH' : redefinition; different type modifiers
jkrCommented:
What is your exact code? If should be something like

// foward declaration
short TestWithSEH(_clsACD* pWinDLL);

//... some other code

short TestWithSEH(_clsACD* pWinDLL)
{
     short ret;

     __try
     {
     // TODO: Add your control notification handler code here


     pWinDLL->CreateDispatch("WinDLL.clsACD");
     ret = pWinDLL->GetCassStatus();
     }
     __except(EXCEPTION_CONTINUE_EXECUTION){
          puts ( "We knew that this would go wrong...");
     }

    return ret;
}

//... some more code

    EnableWindow(FALSE);
    _clsACD WinDLL;
    short ret = TestWithSEH(&WinDLL);
    EnableWindow(TRUE);
James_ClementsAuthor Commented:
ok my bad, Now it's working

but I am back to original problem that I can't Step through any further,
Write after executing this code
    ret = pWinDLL->GetCassStatus();

Error I get is

First-chance exception in WinDemo.exe (NTDLL.Dll): 0xC0000008: Invalid Handle.
jkrCommented:
You can ignore first-chance exceptions. See http://support.microsoft.com/support/kb/articles/q105/6/75.asp

A first chance exception is called so as it is passed to a debugger before the application 'sees' it. This is done by sending a 'EXCEPTION_DEBUG_EVENT' to the debugger, which can now decide whether it is passed to the apllication to handle it or 'ignore' it (e.g. like an 'EXCEPTION_BREAKPOINT' aka 'int 3'). If the exception isn't handled, it becomes a '2nd chance' exception, the debugger 'sees' it the 2nd time and will usually terminate the program (without using a debugger, these exceptions end up at 'UnhandledExceptionFilter()' which will also signal the exception to the user with one of these 'nice' message boxes and terminate the program, also...)
itsmeandnobodyelseCommented:
>>>> but I am back to original problem that I can't Step through any further

If you have the source code and a debug version of the dll, you might add the dll in Project-Settings-Debug Tab-Category Additional Dlls. Then, you should be able to step into the function GetCassStatus.

As jkr explained, the 'First Chance Exception' doesn't prevent your prog to go on. If it hangs at that call, you need to check the dll code if available or check the docs.

Regards, Alex
James_ClementsAuthor Commented:
I don't have code for Dll that has function(GetCassStatus). and I am trying to debug in Visual C++ 6.0.
It's only creates exception when I am in debug mode and doesn't let me step forward.
so do you have any other suggestions.
jkrCommented:
>>It's only creates exception when I am in debug mode and doesn't let me step forward.

That's what I wrote - what you are seeing is an exception that has already been handled successfully, no need to worry about that. Where exactly in the code do you get stuck?
James_ClementsAuthor Commented:
when call is made to function and after it's finished that's when I get error for First-Chance.
At this point it's taking me to [break]-[Disassembly] screen.
After this I can not execute any line of code.
jkrCommented:
>>At this point it's taking me to [break]-[Disassembly] screen.
>>After this I can not execute any line of code.

Which version of VC++ are you using? All you need to do is to set the debugger *not* to stop at first chance exceptions, but only unhandled exceptions. With VC6, go to 'Debug|Exceptions', type 'c0000008' in the 'Number' field, set 'Name' to 'Invalid Handle' and select 'Stop if not handled'. That must be done while running the debugee. In VC7.x, select 'Debug|Exceptions' (at any time) and locate 'Invalid Handle'. If it is not there, pick 'Add...' , enter the exception code and the name and under 'When the exception is thrown', set 'Continue', under 'When the exception is not handled', set 'Break into the Debugger'.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.