NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Using the MarshalAsAttribute

The System.Runtime.InteropServices.MarshalAsAttribute can be applied to a field, parameter or return value within the source of the type definition. For example:

public static extern void PrintMessage(
   [MarshalAs(UnmanagedType.LPWSTR)]String msg);

Or for a field within a class:

class MsgText {
   [MarshalAs(UnmanagedType.LPWSTR)] String msg;
}

And for a return value:

public static extern 
[MarshalAs(UnmanagedType.LPWSTR)] String GetMessage();

The System.Runtime.InteropServices.MarshalAsAttribute uses the System.Runtime.InteropServices.UnmanagedType enum (abbreviated UT throughout this document) to indicate the desired format of the unmanaged type. The above examples all indicate that the msg data should be marshaled as a buffer of Unicode characters (LPWSTR).