title: Will using MarshalAs(UnmanagedType.LPWStr) cleanup memory?
body: <p>I'm trying to write a pinvoke for the ITaskTrigger::GetTriggerString method (defined at <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa381866(v=vs.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/windows/desktop/aa381866(v=vs.85).aspx</a>). If you look at the page, it says that the caller of the method is responsible for freeing the memory (via CoTaskMemFree) of the LPWSTR referenced via the first argument. While I could do that manually in .NET or could write my custom marshaler using ICustomMarshaler, I was wondering if using the MarshalAs(UnmanagedType.LPWStr) attribute for that particular argument will free the memory appropriately.</p>
  
  <p>Can anyone provide some insight?</p>