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 Methods

The methods of the Marshal class are listed below. For a complete list of Marshal class members, see the Marshal Members topic.

Public:

AddRef [To be supplied.]
AddrOfArrayElement Returns the address of an element of an array in the native heap.
AddrOfDelegate Returns the address of a previously pinned delegate object.
AddrOfPinnedObject Returns the address, in managed heap, of an object that was previously pinned against garbage reclamation or movement (by a call to GetPinnedHandle).
AllocCoTaskMem Allocates a block of memory of specified size from the COM task memory allocator.
AllocHGlobal Allocates memory from the process' unmanaged, native, heap.
Copy Overloaded. [To be supplied.]
CreateWrapperOfType [To be supplied.]
DestroyStructure Frees all substructures pointed to by the native memory block.
Equals (inherited from Object) Determines whether the specified Object is the same instance as the current Object. Subclasses are expected to override this method to support value equality (not reference equality).
FreeCoTaskMem Frees a block of memory allocated by the unmanaged COM task memory allocator.
FreeHGlobal Frees memory, previously allocated from from the process' unmanaged, native heap.
FreePinnedHandle Unpins the object previously pinned against garbage reclamation and movement.
GenerateGuidForType [To be supplied.]
GetComInterfaceForObject [To be supplied.]
GetExceptionCode [To be supplied.]
GetExceptionPointers [To be supplied.]
GetHashCode (inherited from Object) Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetHINSTANCE [To be supplied.]
GetIDispatchForObject Returns an IDispatch interface from a managed object.
GetITypeInfoForType [To be supplied.]
GetIUnknownForObject [To be supplied.]
GetLastWin32Error Returns the last error incurred by Win32 code executed via Marshal. Note that the target function must have had the setLastError metadata flag set-- how this is done varies depending upon the source language used.
GetManagedThunkForUnmanagedMethodPtr [To be supplied.]
GetNativeVariantForObject [To be supplied.]
GetObjectForIUnknown Returns an instance of System.Object that represents an unmanaged COM object that is specified by a pointer to its IUnknown interface.
GetObjectForNativeVariant [To be supplied.]
GetPinnedHandle Pins the specified object to prevent it from being garbage collected or moved. (This called must be matched with a subsequent FreePinnedHandle)
GetPinnedObject Returns the object, previously pinned against garbage collection and movement by a call to GetPinnedHandle.
GetType (inherited from Object) Gets the Type of the Object.
GetTypedObjectForIUnknown Returns a managed object of a specified type that represents an unmanaged COM object. NOTE: Type T should be either a COM-imported Type or a sub-type of a COM-imported Type.
GetTypeForITypeInfo Creates a TypeInfo/Type marshaler and passes the provided ITypeInfo to the marshaler. The marshaler then delegates the calls on the Type object to the underlying ITypeInfo interface.
GetTypeInfoName [To be supplied.]
GetTypeLibName [To be supplied.]
GetUnmanagedThunkForManagedMethodPtr [To be supplied.]
IsComObject Indicates whether a specified object represents an unmanaged COM object.
IsTypeVisibleFromCom [To be supplied.]
NumParamBytes Calculate the number of bytes required to hold the parameters for the specified method.
OffsetOf Returns the byte offset for a field within a class used by Marshal.
Prelink Checks that the native method m is type-compatible with the corresponding managed declaration. (This action is performed automatically when the target method is invoked anyway.)
PrelinkAll Performs a Prelink check for all methods on a class.
PtrToStringAnsi Overloaded. Copies all or part of an ANSI string, stored in native heap, to a managed String object.
PtrToStringAuto Overloaded. Copies all or part of a string, stored in native heap, to a managed String object.
PtrToStringUni Overloaded. Copies part or all of a UNICODE string, stored in native heap, to a managed String object.
PtrToStructure Overloaded. Marshals data from an unmanaged block of memory to a managed object.
QueryInterface Requests a pointer to a specified interface on an unmanaged COM object.
ReadByte Overloaded. Reads a single byte from native heap
ReadInt16 Overloaded. Reads a 16-bit integer from native heap
ReadInt32 Overloaded. Reads a 32-bit integer from native heap.
ReadInt64 Overloaded. Reads a 64-bit integer from native heap.
ReAllocCoTaskMem [To be supplied.]
ReAllocHGlobal [To be supplied.]
Release Decrements the reference count on a specified unmanaged COM interface.
ReleaseComObject Releases the COM component and, if the reference hits 0, zombies this object. Further usage of this object might throw an exception.
ReleaseThreadCache Forces the aggressive release of the current thread's cache. There may be a thread-based cache of COM components.
SizeOf Overloaded. Returns the size, in bytes, of a class used via Marshal.
StringToCoTaskMemAnsi Copies the contents of a string to block of memory allocated from the unmanaged COM task allocator. The characters of the string are copied as ANSI characters.
StringToCoTaskMemAuto Copies the contents of a string to a block of memory allocated from the unmanaged COM task allocator. The characters of the string are copied as either ANSI or Unicode characters, depending on the operating system where the code is executing. On Windows 95 or Windows 98, the characters are copied as ANSI characters. On Windows NT 4.0 or Windows 2000, the characters are copied as Unicode characters.
StringToCoTaskMemUni Copies the contents of a string to block of memory allocated from the unmanaged COM task allocator. The characters of the string are copied as Unicode characters.
StringToHGlobalAnsi Copies the contents of a managed String object into native heap, converting into ASCII format on-the-fly. The method allocates the required, native heap memory.
StringToHGlobalAuto Copies the contents of a managed String object into native heap, converting into ASCII format on-the-fly if required. The method allocates the required, native heap memory.
StringToHGlobalUni Copies the contents of a managed String object into native heap. (source and destination are both UNICODE). The method allocates the required, native heap memory.
StructureToPtr Marshals data from a managed object to an unmanaged block of memory. This method copies the contents of structure to the block of memory pointed to by ptr. If fDeleteOld is true, the buffer originally pointed to by ptr will be deleted. This is accomplished by calling the appropriate 'delete' API on the embedded pointer. StructureToPtr does this tidy-up for every reference field specified in the 'mirror' managed class.
ToString (inherited from Object) Returns a String that represents the current Object.
UnsafeAddrOfPinnedArrayElement [To be supplied.]
WriteByte Overloaded. Writes a single byte value into native heap.
WriteInt16 Overloaded. Writes a 16-bit integer value into native heap.
WriteInt32 Overloaded. Writes a 32-bit integer value into native heap.
WriteInt64 Overloaded. Writes a 64-bit integer value into native heap.

Protected:

Finalize (inherited from Object) Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by the Garbage Collector (GC). This method may be ignored by the runtime; therefore, necessary cleanup operations should be done elsewhere.
MemberwiseClone (inherited from Object) Creates a shallow copy of the current Object.

See Also

Marshal Class | System.Runtime.InteropServices Namespace