Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Howto: return _com_error info to wmi client from wmi method provider method ExecMethodAsync

22 views
Skip to first unread message

Anthony Lamark

unread,
May 9, 2014, 7:23:45 PM5/9/14
to
Hi,

I want to return detailed (application specific) error information to wmi clients that call a wmi method provider. In the method ExecMethodAsync, I have a _com_error object that is populated with the error. I am experimenting and have tried calling SetErrorInfo (hoping for some magic! :-) ) but I think the way to do it lies in the call to the SetStatus method of the passed in IWbemObjectSink.

SetStatus takes a IWbemClassObject* as its last argument and the documentation about that parameter is:
"In cases where a complex error or status object is returned, this contains a pointer to the error object. If the object is required after SetStatus returns, the called object must use the AddRef method on the pointer before the called object returns."

I thought that the CIMV2 repository might have some predefined error classes (maybe even mimicing _com_error->IErrorInfo) but I did not see anything that jumped out at me. If required, I can add an error class to the MOF.

So, I am looking for some advice or example code that achieves this.

On the client side (using C# as the example), it would be awesome if I could just have them:

try
{
outParams = m_ManagementClass.InvokeMethod(x,params,options);
}
catch (System.Runtime.InteropServices.COMException ce)
{
//handle error
}

Thanks very much in advance!
0 new messages