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 )]
Method, parameter, field, and property declarations.
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.
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(); }
C# Attributes | COM InterOp Tutorial | Default marshaling table