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!

marshal

Describes the unmanaged marshaling format for a parameter, field, or method return value.

[marshal(
   unmanagedType,
   Cookie=cookie,
   IID=iid,
   Marshaler=marshaler,
   SubType=subtype,
   Size=size
)]

Applies To

Method, parameter, field, and property declarations.

Parameters

unmanagedtype
An UnmanagedType value specifying the unmanaged marshaling format.
cookie (Optional)
A string to be passed to the marshaler.
iid (Optional)
A string specifying the GUID when unmanagedtype is UnmanagedType.Interface.
marshaler (Optional)
A string specifying a marshaling class.
subtype (Optional)
An UnmanagedType value specifying the subsidiary type for UnmanagedType.Ptr and UnmanagedType.FixedArray types.
size (Optional)
An int; the size of a fixed-size array or string.

Remarks

marshal is a single-use attribute. marshal is an alias for System.InterOp.MarshalAttribute.

The marshal attribute indicates the manner in which to marshal the item. For example, a parameter of type string might be marshaled as a BStr, an LPStr, an LPWStr, an LPTStr, or a FixedSysString. For methods, marshal specifies how to marshal the return value of the method.

Example

In the following interface definition, the method AddSourceFilter takes one parameter of type string marshaled as a BStr and one of type object marshaled as an IDispatch; the return value of FilterCollection, an object, is marshaled as an IDispatch.

[guid("56A868B1-0AD4-11CE-B03A-0020AF0BA771"), 
   InterfaceType(ComInterfaceType.Dual)] 
interface IMediaControlFilter // can not list any base interfaces here 
{ 
   [returnshresult(true)] 
   void AddSourceFilter(
     [in, marshal(UnmanagedType.BStr)] string strFilename,
     [out, marshal(UnmanagedType.IDispatch)] object ppUnk
   );
   [returnshresult(true), marshal(UnmanagedType.IDispatch)] 
   object FilterCollection();
}

See Also

C# Attributes | COM InterOp Tutorial | Default marshaling table