title: Marshalling VARIANT across ABI boundaries in a WinRT component
body: <p>I am porting our component which is written in C++ at its core and has both an ActiveX and a .Net shell. The component internally uses the VARIANT type in many places. Some public properties (get/set) and methods of this component's arguments are of the VARIANT type in the ActiveX implementation and System::Object in the .Net implementation. Internally in our code we use the VARIANT directly.</p>
  
  <p>When implementing the ActiveX component, I did not need to do any marshaling since VARIANT is an OLE/COM type.</p>
  
  <p>When implementing .Net component, I used similar to this:</p>
  
  <pre><code>VARIANT var;
  
  //...
  
  //Initialize the VARIANT value
  
  //...
  
  
  System::IntPtr p( &amp;var );
  
  System::Object ^o = System::Runtime::InteropServices::Marshal::GetObjectForNativeVariant(p );
  
  return o;
  </code></pre>
  
  <p>In WinRT, there does not seem to be any similar Marshal class that will do the job. According to MSDN "The WinRT Platform::Runtime::InteropServices namespace is intended for internal use only, and is not intended to be used for development."</p>
  
  <p>What are my options? Surely there must be an existing class to do the work of marshalling a VARIANT across ABI boundaries. I don't want to write such a marshaller and then find out that it already exists !</p>
  
  <p>Any help would be much appreciated.</p>