E_UNEXPECTED Catastrophic failure when calling COM exe server with a parameter of IPictureDisp

Jeongmo Koo 26 Reputation points
2022-07-21T16:37:02.78+00:00

Hi
I have a c++ client application and c++ COM EXE Server.
COM Exe has FromPicture method like the below.
STDMETHODIMP CMyComServer::FromPicture(IPictureDisp* picture)
{
...
return S_OK;
}
When I call this method in c++ client application like the below,
The COM error "E_UNEXPECTED Catastrophic failure" is caught.
No issue with other COM methods with passing string or integer.
So it seems that IPictureDisp cannot be passed to COM EXE server.
(I believe the same COM method works fine if it's a COM dll server)
I will appreciate if you leave any comment/suggestion.

   try  
{  
	hr = m_pMyComServer->FromPicture(pIPict);  
	pIPict->Release();  
	pIPict = NULL;  
catch (_com_error comErr)  
{
Developer technologies C++
{count} votes

Accepted answer
  1. RLWA32 49,536 Reputation points
    2022-07-21T23:24:44.977+00:00

    You can use an IStream* interface pointer to pass your picture object from the COM client to the COM Server.
    The IPictureDisp object also implements IPersistStream. That is what the COM client can use to save the picture to a stream. The COM Server can then use IPersistStream to load the picture object from the stream.

    The site wouldn't accept a code post so I'm posting images instead.

    COM Client -

    223792-comclient.png

    COM Server -

    223811-comserver.png

    Before sending stream from client to server -

    223753-combefore.png

    After stream sent with display of image by server -

    223782-comafter.png

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jeongmo Koo 26 Reputation points
    2022-07-22T22:53:57.527+00:00

    Awesome!!! RLWA32-6355
    My resolution was to save image to a temporary file and then pass file path to COM server.
    But your one are much better than this.
    I appreciate that.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.