title: How to implement IMarshal for custom marshalling interface from out-of-proc server
body: <p>I am trying to figure out how to implement custom marshalling for an out-of-proc COM server when it fires an event.  The server implements the IConnectionPoint interface.  One of the methods on the interface that it calls to signal an event takes a pointer to an interface (Call it IMyEventData.).  The class that implements IMyEventData in the server also implements IMarshal. When my server fires the event, I get the calls to IMarshal that I expect, including GetMarshalSizeMax, GetUnmarshalClass, and MarshalInterface.  So far, so good.</p>
  
  <p>I have implemented the unmarshaller in a separate DLL that is registered on the system.  Right after the server handles the MarshalInterface call, my unmarshaller DLL gets loaded into the client, but the calls that I get on its IMarshal interface are not what I expect. The calls are to GetUnmarshalClass, GetMarshalSizeMax, and MarshalInterface.  In all of these calls, the context is in-proc, apparently attempting to marshal across apartments rather than process boundaries.  I never get the expected call to UnmarshalInterface.  When I run both client and server under the debugger, each displays an exception in the output window right after the calls to my unmarshaller's IMarshal interface are made, indicating that an incorrect parameter error (0x80070057) occurred.</p>
  
  <p>Can anyone tell me what I am doing wrong?  I had expected my unmarshaller to get a call to IMarshal::UnmarshalInterface so that it would get access to the data that the server supplied in the call to IMarshal::MarshalInterface.  I must be missing something basic here.</p>
  
  <p>Thanks.</p>
  
  <p>Wayne</p>