API Support Forum
OEC API > API Support > OnError event parameter C++/COM type
Author Topic: OnError event parameter C++/COM type
(5 messages, Page 1 of 1)
Moderators: VPfau
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Jul 27, 2007 @ 12:39 PM             Msg. 1 of 5
For the OnError event, what is the C++/COM type that the given dispatch pointer parameter is pointing to? I see in .NET it's supposed to be System::Exception, but I don't know the equivalent class in C++/COM to work with that object.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Jul 27, 2007 @ 01:40 PM             Msg. 2 of 5
you can see it in the generated file OECAPICOM.tlh :

_DOECClientEventInterface : IDispatch
{
...
HRESULT OnError (struct _Exception * ex );

the _Exception interface is defined in the "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" library and automatically imported (with all .NET types) by reference when importing oecapicom.tlb .
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Jul 27, 2007 @ 05:44 PM             Msg. 3 of 5
Thank you, I did not see that declaration. I still had some trouble figuring out how to use _Exception until I realized that mscorlib::_Exception was defined where OECAPICOM::_Exception was not. Unfortunately I ended up with what looks like a corrupt or invalid string, so I'm still having trouble getting useful information out of the OnError event.

The C++ COM API sample doesn't include the OnError event, but I think a sample of how to use that and the exception parameter that's given would be helpful.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Jul 30, 2007 @ 03:16 PM             Msg. 4 of 5
you can use something like this:

mscorlib::_ExceptionPtr _ex = ex;
_bstr_t message = _ex->Message;
log << "OnError: " << message << std::endl;

we will add this to next release of the COM API sample.
SierraChart
Posts: 111
Joined: Jul 17, 2007


Posted: Jul 30, 2007 @ 05:24 PM             Msg. 5 of 5
That works. Thank you.