Unable to catch exception thrown from ActiveX control in an MFC client 
Author Message
 Unable to catch exception thrown from ActiveX control in an MFC client

Hi,

From my ATL ActiveX Composite control, I am throwing an exception using
'CComCoClass::Error' method. From the VB client, I am able to receive the
error description (that is I am able to catch and handle the exception). But
from MFC client I couldn't catch it (in the sense, program crashes before
coming to the catch block itself).

When I debugged, I found that a call to 'Invoke' method successfully returns
EXCEPINFO structure (after duly filling it with exception info). Above
mentioned call to 'Invoke' method is occuring in
'COleDispatchDriver::InvokeHelperV' method in OleDisp2.cpp file. Crash is
occuring in the same method ('COleDispatchDriver::InvokeHelperV' ), exactly
at the point where the statement 'THROW(pException)' is found.

try
{
        /*this  is the method which will throw the exception*/
        spMyInterface->DoSomething( );  /*Getting crashed here*/
        .
        .
        .

Quote:
}

catch(_com_error& e)
{
    . /*this point is never reached*/
    .

Quote:
}

Any solution for this?

Thanks,
Ganesh.



Wed, 15 Oct 2003 00:41:45 GMT  
 Unable to catch exception thrown from ActiveX control in an MFC client
Thanks for the reply. Even with 'COleDispatchException*', exception is not
getting caught. i.e.

try
{
        /*this  is the method which will throw the exception using
'CComCoClass::Error'  method*/
        spMyInterface->DoSomething( );  /*Getting crashed here*/
        .

Quote:
}

catch(_com_error& e)
{
    . /*this point is never reached*/
    .
Quote:
}

catch(COleDispatchException* pobjDispatchException)
{
    . /*this point is never reached*/
    .
Quote:
}

catch(...)
{
    . /*this point is never reached*/
    .

Quote:
}

Any clue?

Thanks,
Ganesh.

----------------------------------------------------



Quote:
> That's because pException is a COleDispatchException *, not a _com_error

&.

----------------------------------------------------


Subject: Unable to catch exception thrown from ActiveX control in an MFC
client
Date: Friday, April 27, 2001 11:41 AM

Hi,

From my ATL ActiveX Composite control, I am throwing an exception using
'CComCoClass::Error' method. From the VB client, I am able to receive the
error description (that is I am able to catch and handle the exception). But
from MFC client I couldn't catch it (in the sense, program crashes before
coming to the catch block itself).

When I debugged, I found that a call to 'Invoke' method successfully returns
EXCEPINFO structure (after duly filling it with exception info). Above
mentioned call to 'Invoke' method is occuring in
'COleDispatchDriver::InvokeHelperV' method in OleDisp2.cpp file. Crash is
occuring in the same method ('COleDispatchDriver::InvokeHelperV' ), exactly
at the point where the statement 'THROW(pException)' is found.

try
{
        /*this  is the method which will throw the exception*/
        spMyInterface->DoSomething( );  /*Getting crashed here*/
        .
        .
        .

Quote:
}

catch(_com_error& e)
{
    . /*this point is never reached*/
    .

Quote:
}

Any solution for this?

Thanks,
Ganesh.



Wed, 15 Oct 2003 02:30:38 GMT  
 Unable to catch exception thrown from ActiveX control in an MFC client
That's because pException is a COleDispatchException *, not a _com_error &.


Wed, 15 Oct 2003 02:14:13 GMT  
 Unable to catch exception thrown from ActiveX control in an MFC client
Hi,

Never mind. Problem was something else. The ActiveX control method which
will raise the exception is accepting a VARIANT as an [out] parameter.
Before raising the exception I was just intializing the type (pVar->vt =
VT_ARRAY | VT_BSTR) without intializing the data (pVar->parray). Therefore,
from the client side, CComVariant::Clear has raised that exception (Clear
was called before going to the catch block).

Thanks,
Ganesh.


Quote:
> Thanks for the reply. Even with 'COleDispatchException*', exception is not
> getting caught. i.e.

> try
> {
>         /*this  is the method which will throw the exception using
> 'CComCoClass::Error'  method*/
>         spMyInterface->DoSomething( );  /*Getting crashed here*/
>         .
> }
> catch(_com_error& e)
> {
>     . /*this point is never reached*/
>     .
> }
> catch(COleDispatchException* pobjDispatchException)
> {
>     . /*this point is never reached*/
>     .
> }
> catch(...)
> {
>     . /*this point is never reached*/
>     .
> }

> Any clue?

> Thanks,
> Ganesh.

> ----------------------------------------------------



> > That's because pException is a COleDispatchException *, not a _com_error
> &.

> ----------------------------------------------------


> Subject: Unable to catch exception thrown from ActiveX control in an MFC
> client
> Date: Friday, April 27, 2001 11:41 AM

> Hi,

> From my ATL ActiveX Composite control, I am throwing an exception using
> 'CComCoClass::Error' method. From the VB client, I am able to receive the
> error description (that is I am able to catch and handle the exception).
But
> from MFC client I couldn't catch it (in the sense, program crashes before
> coming to the catch block itself).

> When I debugged, I found that a call to 'Invoke' method successfully
returns
> EXCEPINFO structure (after duly filling it with exception info). Above
> mentioned call to 'Invoke' method is occuring in
> 'COleDispatchDriver::InvokeHelperV' method in OleDisp2.cpp file. Crash is
> occuring in the same method ('COleDispatchDriver::InvokeHelperV' ),
exactly
> at the point where the statement 'THROW(pException)' is found.

> try
> {
>         /*this  is the method which will throw the exception*/
>         spMyInterface->DoSomething( );  /*Getting crashed here*/
>         .
>         .
>         .
> }
> catch(_com_error& e)
> {
>     . /*this point is never reached*/
>     .
> }

> Any solution for this?

> Thanks,
> Ganesh.



Wed, 15 Oct 2003 07:15:47 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Unable to catch exception thrown from ActiveX control in an MFC client

2. No way to catch exceptions thrown from MFC

3. Catching exceptions thrown from another thread?

4. Does Finally execute try Catch throws an Exception?

5. throwing exception from COM and catching it in ASP

6. Help on throwing/catching exceptions

7. How to catch all exceptions thrown?

8. catching exceptions thrown from web services

9. Unable to use e.Message() when catching exceptions.

10. Throw exception from ATL COM for both VB and VC++ client

11. Question: Catching errors from a VB ActiveX control in Visual C++ using MFC

12. Specify a client area on a ActiveX MFC control

 

 
Powered by phpBB® Forum Software