mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.5000.0 2.0.0.0 4.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Object

The static methods defined on the class are essential to working with unmanaged code. Most methods defined in this class are typically used by developers who want to provide a bridge between the managed and unmanaged programming models. For example, the method copies ANSI characters from a specified string (in the managed heap) to a buffer in the unmanaged heap. It also allocates the target heap of the right size.

The common language runtime provides specific marshaling capabilities. For details on marshaling behavior, see Interop Marshaling.

The Read and Write methods in the class support both aligned and unaligned access.

Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  The common language runtime manages the reference count of a COM object for you, making it unnecessary to use this method directly. In rare cases, such as testing a custom marshaler, you might find it necessary to manipulate an object's lifetime manually. After calling , you must decrement the reference count by using a method such as . Do not rely on the return value of , as it can sometimes be unstable.

  You can call , , or to obtain an value that represents an IUnknown interface pointer. You can also use these methods and the method on managed objects to obtain the COM interfaces represented by the managed object's COM callable wrapper. If you are not familiar with the details of this wrapper type, see [<topic://cpconcomcallablewrapper>].

  Increments the reference count on the specified interface.

  The new value of the reference count on the parameter.

  The interface reference count to increment.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is one of two memory allocation API methods in the class. ( is the other.) The initial memory content returned is undefined, and the allocated memory can be larger than the requested number of bytes. This method exposes the COM CoTaskMemAlloc function, which is referred to as the COM task memory allocator.

  Allocates a block of memory of specified size from the COM task memory allocator.

  An integer representing the address of the block of memory allocated. This memory must be released with .

  The size of the block of memory to be allocated.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)
  System.IntPtr ``

  is one of two memory allocation methods in the class. ( is the other.) This method exposes the Win32 LocalAlloc function from Kernel32.dll.

  When calls LocalAlloc, it passes a LMEM_FIXED flag, which causes the allocated memory to be locked in place. Also, the allocated memory is not zero-filled.

  Allocates memory from the unmanaged memory of the process by using the specified number of bytes.

  A pointer to the newly allocated memory. This memory must be released using the method.

  The required number of bytes in memory.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)
  System.IntPtr ``

  is one of two memory allocation methods in the class. ( is the other.) This method exposes the Win32 LocalAlloc function from Kernel32.dll.

  When calls LocalAlloc, it passes a LMEM_FIXED flag, which causes the allocated memory to be locked in place. Also, the allocated memory is not zero-filled.

  Allocates memory from the unmanaged memory of the process by using the pointer to the specified number of bytes.

  A pointer to the newly allocated memory. This memory must be released using the method.

  The required number of bytes in memory.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  exposes the COM BindToMoniker method, which produces an object that you can cast to any COM interface you require. This method provides the same functionality as the GetObject method in Visual Basic 6.0 and vbprvblong.

  Gets an interface pointer identified by the specified moniker.

  An object containing a reference to the interface pointer identified by the parameter. A moniker is a name, and in this case, the moniker is defined by an interface.

  The moniker corresponding to the desired interface pointer.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  is used for object pooling functionality and should never be called by user code directly.

  Changes the strength of an object's COM Callable Wrapper (CCW) handle.

  The object whose CCW holds a reference counted handle. The handle is strong if the reference count on the CCW is greater than zero; otherwise, it is weak. true to change the strength of the handle on the parameter to weak, regardless of its reference count; false to reset the handle strength on to be reference counted.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed 8-bit unsigned integer array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed character array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed double-precision floating-point number array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed 16-bit signed integer array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed 64-bit signed integer array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed 8-bit unsigned integer array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed character array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed double-precision floating-point number array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed 16-bit signed integer array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed 32-bit signed integer array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed 64-bit signed integer array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Therefore, the unmanaged data that corresponds to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling the method.

  Copies data from an unmanaged memory pointer to a managed array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  Unmanaged, C-style arrays do not contain bounds information, which prevents the and parameters from being validated. Thus, the unmanaged data corresponding to the parameter populates the managed array regardless of its usefulness. You must initialize the managed array with the appropriate size before calling this method.

  Copies data from an unmanaged memory pointer to a managed single-precision floating-point number array.

  The memory pointer to copy from. The array to copy to. The zero-based index in the destination array where copying should start. The number of array elements to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` ``

  You can use this method to copy a subset of a one-dimensional managed array to an unmanaged C-style array.

  Copies data from a one-dimensional, managed single-precision floating-point number array to an unmanaged memory pointer.

  The one-dimensional array to copy from. The zero-based index in the source array where copying should start. The memory pointer to copy to. The number of array elements to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  The method aggregates the inner managed pointer of a managed object with the specified outer pointer, and then returns an inner IUnknown pointer of the managed object.

  Aggregates a managed object with the specified COM object.

  The inner IUnknown pointer of the managed object.

  The outer IUnknown pointer. An object to aggregate.
- Method
  4.0.0.0
  System.IntPtr `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` ``

  converts one COM class type, typically the generic __ComObject type, to another COM class type. The input COM object, represented by parameter , is a Runtime Callable Wrapper (RCW).

  Both the and parameters must be classes whose signatures are attributed with . The Tlbimp.exe (Type Library Importer) tool applies this attribute for you when it imports a type library. If you create the RCW manually in source code, you should apply this attribute to the managed signature that represents the original coclass to signify its COM origins.

  Tlbimp.exe imports a COM coclass as a managed class and an interface. The coclass interface has the same name as the original coclass, and the managed class has the original coclass name appended with "Class". For example, a coclass called MyCoclass becomes a coclass interface called MyCoclass and a managed class called MyCoclassClass. Since must be a class, not an interface, be sure to specify the managed class (MyCoclassClass) and not the coclass interface.

  You lose the identity of the input COM object because a new RCW instance wraps the IUnknown pointer exposed by the original RCW.

  Wraps the specified COM object in an object of the specified type.

  The newly wrapped object that is an instance of the desired type.

  The object to be wrapped. The type of wrapper to create.
- Method
  4.0.0.0
  TWrapper `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.Void `` ``

  You can use this method to free reference-type fields, such as strings, of an unmanaged structure. Unlike its fields, a structure can be a value type or a reference type. Value-type structures that contain value-type fields (all blittable) have no references whose memory must be freed. The method uses this method to prevent memory leaks when reusing memory occupied by a structure.

  calls the COM SysFreeString function, which, in turn, frees an allocated string.

  In addition to , the class provides two other memory-deallocation methods: and .

  Frees all substructures that the specified unmanaged memory block points to.

  A pointer to an unmanaged block of memory. Type of a formatted class. This provides the layout information necessary to delete the buffer in the parameter.
- Method
  4.0.0.0
  System.Void ``

  You can use this method to free reference type fields, such as strings, of an unmanaged structure. Unlike its fields, a structure can be a value type or a reference type. Value type structures that contain value type fields (all blittable) have no references whose memory must be freed. The method uses this method to prevent memory leaks when reusing memory occupied by a structure.

  calls the COM SysFreeString function, which, in turn, frees an allocated string.

  [Supported in the .NET Framework 4.5.1 only]

  Frees all substructures of a specified type that the specified unmanaged memory block points to.

  A pointer to an unmanaged block of memory. The type of the formatted structure. This provides the layout information necessary to delete the buffer in the parameter.
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  The method releases the managed reference to a COM object. Calling this method is equivalent to calling the method in a loop until it returns 0 (zero).

  When the reference count on the COM object becomes 0, the COM object is usually freed, although this depends on the COM object's implementation and is beyond the control of the runtime. However, the RCW can still exist, waiting to be garbage-collected.

  The COM object cannot be used after it has been separated from its underlying RCW. If you try to call a method on the RCW after its reference count becomes 0, a will be thrown.

  Releases all references to a Runtime Callable Wrapper (RCW) by setting its reference count to 0.

  The new value of the reference count of the RCW associated with the parameter, which is 0 (zero) if the release is successful.

  The RCW to be released.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  Like and , you can use this method to deallocate memory. calls the COM SysFreeString function, which frees memory allocated by any of the following unmanaged methods: SysAllocString, SysAllocStringByteLen, SysAllocStringLen, SysReAllocString, SysReAllocStringLen. You can call unmanaged methods such as these with platform invoke. For details, see [<topic://cpconconsumingunmanageddllfunctions>].

  Frees a BSTR using the COM SysFreeString function.

  The address of the BSTR to be freed.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  You can use to free any memory allocated by , , or any equivalent unmanaged method. If the parameter is null, the method does nothing.

  exposes the COM CoTaskMemFree function, which frees all bytes so that you can no longer use the memory that the parameter points to.

  In addition to , the class provides two other memory-deallocation methods: and .

  Frees a block of memory allocated by the unmanaged COM task memory allocator.

  The address of the memory to be freed.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Void ``

  You can use to free any memory from the global heap allocated by , , or any equivalent unmanaged API method. If the parameter is the method does nothing.

  exposes the LocalFree function from Kernel32.DLL, which frees all bytes so that you can no longer use the memory pointed to by .

  In addition to , the class provides two other memory-deallocation API methods: and .

  Frees memory previously allocated from the unmanaged memory of the process.

  The handle returned by the original matching call to .
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Guid ``

  If the type has a GUID in the metadata, it is returned. Otherwise, a GUID is automatically generated. You can use this method to programmatically determine the COM GUID for any managed type, including COM-invisible types. Class interfaces are the only exception because they do not correspond to a managed type. provides the same functionality as the property.

  Returns the globally unique identifier (GUID) for the specified type, or generates a GUID using the algorithm used by the Type Library Exporter (Tlbexp.exe).

  An identifier for the specified type.

  The type to generate a GUID for.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  If the type has a ProgID in the metadata, that ProgID is returned. Otherwise, a ProgID is generated based on the fully qualified name of the type.

  Returns a programmatic identifier (ProgID) for the specified type.

  The ProgID of the specified type.

  The type to get a ProgID for.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  exposes the COM GetActiveObject function from OLEAUT32.DLL; however, the latter expects a class identifier (CLSID) instead of the programmatic identifier () expected by this method. To obtain a running instance of a COM object without a registered , use platform invoke to define the COM GetActiveObject function. For a description of platform invoke, see [<topic://cpconconsumingunmanageddllfunctions>].

  ## ProgID and CLSID

  Keys in the HKEY_CLASSES_ROOT subtree of the registry contain a variety of subkey types. Most of the subkeys are ProgIDs, which map a user-friendly string to a CLSID. Applications often use these human-readable strings instead of the numeric CLSIDs. Often, a component has a version-independent ProgID that is mapped to the latest version of the component that is installed on the system.

  Applications and components primarily use ProgIDs to retrieve their corresponding CLSIDs.

  Obtains a running instance of the specified object from the running object table (ROT).

  The object that was requested; otherwise null. You can cast this object to any COM interface that it supports.

  The programmatic identifier (ProgID) of the object that was requested.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  This method returns an interface pointer that represents the requested interface on the specified object. It is particularly useful if you have an unmanaged method that expects to be passed an interface pointer. Calling an object with this method causes the reference count to increment on the interface pointer before the pointer is returned. Always use to decrement the reference count once you have finished with the pointer. You must adhere to the rules defined by COM when using raw COM interface pointers.

  is useful when calling a method that exposes a COM object parameter as an type, or with custom marshaling. Although less common, you can use this method on a managed object to obtain a pointer to the object's COM callable wrapper. For example, you can use on a managed object that is exported to COM to obtain an interface pointer for . You cannot obtain a pointer to a class interface since a class interface lacks the corresponding type to pass to the second parameter (). Instead, use to invoke the members on the default interface of the COM callable wrapper, which is usually an auto-dispatch class interface.

  The method overload allows query interface customization by default. To specify whether to apply query interface customization, use the method overload.

  For additional information, see the COM Callable Wrapper, Runtime Callable Wrapper, and Introducing the Class Interface topics.

  Returns a pointer to an IUnknown interface that represents the specified interface on the specified object. Custom query interface access is enabled by default.

  The interface pointer that represents the specified interface for the object.

  The object that provides the interface. The type of interface that is requested.
- Method
  4.0.0.0
  System.IntPtr `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  This method is the same as except that it returns null if the caller is not in the same context as the object. It is particularly useful if you have an unmanaged method that expects to be passed an interface pointer.

  Returns an interface pointer that represents the specified interface for an object, if the caller is in the same context as that object.

  The interface pointer specified by that represents the interface for the specified object, or null if the caller is not in the same context as the object.

  The object that provides the interface. The type of interface that is requested.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` ``

  All COM objects wrapped in a Runtime Callable Wrapper have an associated hash table, which retrieves. adds data to the hash table. You should never have to call either method from your code.

  Retrieves data that is referenced by the specified key from the specified COM object.

  The data represented by the parameter in the internal hash table of the parameter.

  The COM object that contains the data that you want. The key in the internal hash table of to retrieve the data from.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  The zero-based slot number returned by this method accounts for three IUnknown and possibly four IDispatch methods, making the value of the first available slot either 3 or 7. provides the opposite functionality of .

  You can use this method to retrieve slot numbers for members of interfaces that are not visible from COM and for members of private interfaces. The slot numbers returned correspond to the v-table numbers that would be reserved if the type was exposed to COM. COM-invisible members actually occupy a slot in an exposed v-table, even though the COM client cannot use the slot. You cannot use on a class interface by passing from a class. For additional information, see Introducing the Class Interface.

  Retrieves the virtual function table (v-table or VTBL) slot for a specified type when that type is exposed to COM.

  The VTBL slot identifier when it is exposed to COM.

  An object that represents an interface method.
- Method
  2.0.0.0
  4.0.0.0
  System.Delegate `` ``

  In versions 1.0 and 1.1 of the .NET Framework, it was possible to pass a delegate representing a managed method to unmanaged code as a function pointer, allowing the unmanaged code to call the managed method through the function pointer. It was also possible for the unmanaged code to pass that function pointer back to the managed code, and the pointer was resolved properly to the underlying managed method.

  In the .NET Framework 2.0 and later versions, you can use the and methods to marshal delegates in both directions. With , is imported as a . A can be obtained for a managed delegate by calling and passed as a parameter; it can then be called from inside the unmanaged method. Note that the parameter marshaler can also marshal function pointers to delegates in the .NET Framework 2.0 and later versions.

  The method has the following restrictions:

  Generics are not supported in interop scenarios.

  You cannot pass an invalid function pointer to this method.

  You can use this method only for pure unmanaged function pointers.

  You cannot use this method with function pointers obtained through C++ or from the method.

  You cannot use this method to create a delegate from a function pointer to another managed delegate.

  Converts an unmanaged function pointer to a delegate.

  A delegate instance that can be cast to the appropriate delegate type.

  The unmanaged function pointer to be converted. The type of the delegate to be returned.
- Method
  4.0.0.0
  TDelegate ``

  You can use the and methods to marshal delegates in both directions.

  The method has the following restrictions:

  You cannot pass an invalid function pointer to this method.

  You can use this method only for pure unmanaged function pointers.

  You cannot use this method with function pointers obtained through C++ or from the method.

  You cannot use this method to create a delegate from a function pointer to another managed delegate.

  [Supported in the .NET Framework 4.5.1 only]

  Converts an unmanaged function pointer to a delegate of a specified type.

  A instance of the specified delegate type.

  The unmanaged function pointer to convert. The type of the delegate to return.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method returns the zero-based, v-table number for an interface or a class. When used on a class, the slot number returned refers to the class interface for the class. If the class interface is auto-dual, this method always returns -1 to indicate that the dispatch-only interface does not expose a v-table to managed clients. You can use and in conjunction with to pass slots within a specified range. For additional information, see Introducing the Class Interface.

  Retrieves the last slot in the virtual function table (v-table or VTBL) of a type when exposed to COM.

  The last VTBL slot of the interface when exposed to COM. If the parameter is a class, the returned VTBL slot is the last slot in the interface that is generated from the class.

  A type that represents an interface or class.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  is exposed for compiler support of structured exception handling (SEH) only. If this method is called before an exception is thrown, it returns 0x0.

  Retrieves a code that identifies the type of the exception that occurred.

  The type of the exception.

- Method
  2.0.0.0
  4.0.0.0
  System.Exception ``

  Use the method to get an based on an HRESULT without having to call the method and catch the exception.

  The current IErrorInfo interface is used to construct the exception.

  For the mapping from each HRESULT to its comparable exception class in the .NET Framework, see How to: Map HRESULTs and Exceptions.

  Converts the specified HRESULT error code to a corresponding object.

  An object that represents the converted HRESULT.

  The HRESULT to be converted.
- Method
  2.0.0.0
  4.0.0.0
  System.Exception `` ``

  Use the method to get an based on an HRESULT without having to call the method and catch the exception (thus avoiding the corresponding performance overhead). The parameter supplies additional information about the error, such as its textual description and the globally unique identifier (GUID) for the interface that defined the error.

  Use this method overload if you have custom error information that you have to supply in the conversion.

  For the mapping from each HRESULT to its comparable exception class in the .NET Framework, see How to: Map HRESULTs and Exceptions.

  Converts the specified HRESULT error code to a corresponding object, with additional error information passed in an IErrorInfo interface for the exception object.

  An object that represents the converted HRESULT and information obtained from .

  The HRESULT to be converted. A pointer to the IErrorInfo interface that provides more information about the error. You can specify IntPtr(0) to use the current IErrorInfo interface, or IntPtr(-1) to ignore the current IErrorInfo interface and construct the exception just from the error code.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.IntPtr

  is exposed for compiler support of structured exception handling (SEH) only.

  Retrieves a computer-independent description of an exception, and information about the state that existed for the thread when the exception occurred.

  A pointer to an EXCEPTION_POINTERS structure.

- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  The delegate is converted to a function pointer that can be passed to unmanaged code using the __stdcall calling convention.

  You must manually keep the delegate from being collected by the garbage collector from managed code. The garbage collector does not track references to unmanaged code.

  Converts a delegate into a function pointer that is callable from unmanaged code.

  A value that can be passed to unmanaged code, which, in turn, can use it to call the underlying managed delegate.

  The delegate to be passed to unmanaged code.
- Method
  4.0.0.0
  System.IntPtr `` To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  When dynamic or in-memory, modules do not have an HINSTANCE.

  Returns the instance handle (HINSTANCE) for the specified module.

  The HINSTANCE for ; or -1 if the module does not have an HINSTANCE.

  The module whose HINSTANCE is desired.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  also sets up an IErrorInfo interface for the exception that can be obtained by calling the COM GetErrorInfoNEEDGUID function. You can use this function to return an HRESULT value on a managed class implementation of a COM interface where you apply the . Have the attributed method catch all exceptions and use to return the appropriate HRESULT value. Allowing an exception to propagate outside the method produces incorrect behavior. (In fact, the common language runtime fails to pass an exception to a COM client that calls such a method through a v-table.)

  Note that the method sets the IErrorInfo of the current thread. This can cause unexpected results for methods like the methods that default to using the IErrorInfo of the current thread if it is set.

  Converts the specified exception to an HRESULT.

  The HRESULT mapped to the supplied exception.

  The exception to convert to an HRESULT.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Int32

  The target function must have had the setLastError metadata flag set. For example, the SetLastError field of the must be true. The process for setting this flag depends on the source language used: C# and C++ are false by default, but the Declare statement in Visual Basic is true.

  Returns the HRESULT corresponding to the last error incurred by Win32 code executed using .

  The HRESULT corresponding to the last Win32 error code.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  In managed code, you seldom work directly with the IDispatch interface. However, is useful when calling a method that exposes a COM object parameter as an type, or with custom marshaling. Calling an object with this method causes the reference count to increment on the interface pointer before the pointer is returned. Always use to decrement the reference count once you have finished with the pointer.

  You can also use this method on a managed object to obtain an interface pointer to the COM callable wrapper for the object. For additional information, see [<topic://cpconcomcallablewrapper>].

  Returns an IDispatch interface from a managed object.

  The IDispatch pointer for the parameter.

  The object whose IDispatch interface is requested.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  This method is the same as except that it returns null if the caller is not in the same context as the object.

  Returns an IDispatch interface pointer from a managed object, if the caller is in the same context as that object.

  The IDispatch interface pointer for the specified object, or null if the caller is not in the same context as the specified object.

  The object whose IDispatch interface is requested.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  This method returns a pointer to an ITypeInfo implementation that is based on the original type. Calling an object with causes the reference count to increment on the interface pointer before the pointer is returned. Always use to decrement the reference count once you have finished with the pointer. You can apply the to replace standard interop marshaling behavior with this custom marshaler.

  Returns a interface from a managed type.

  A pointer to the ITypeInfo interface for the parameter.

  The type whose ITypeInfo interface is being requested.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  In managed code, you seldom work directly with the IUnknown interface. However, is useful when calling a method that exposes a COM object parameter as an type, or with custom marshaling. Calling an object with this method causes the reference count to increment on the interface pointer before the pointer is returned. Always use to decrement the reference count once you have finished with the pointer. This method provides the opposite functionality of the method.

  You can also use this method on a managed object to obtain an interface pointer to the COM Callable Wrapper for the object.

  Returns an IUnknown interface from a managed object.

  The IUnknown pointer for the parameter.

  The object whose IUnknown interface is requested.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  This method is the same as except that it returns null if the caller is not in the same context as the object.

  Returns an IUnknown interface from a managed object, if the caller is in the same context as that object.

  The IUnknown pointer for the specified object, or null if the caller is not in the same context as the specified object.

  The object whose IUnknown interface is requested.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Int32

  exposes the Win32 GetLastError function from Kernel32.DLL. This method exists because it is not safe to make a direct platform invoke call to GetLastError to obtain this information. If you want to access this error code, you must call instead of writing your own platform invoke definition for GetLastError and calling it. The common language runtime can make internal calls to APIs that overwrite the GetLastError maintained by the operating system.

  You can use this method to obtain error codes only if you apply the to the method signature and set the field to true. The process for this varies depending upon the source language used: C# and C++ are false by default, but the Declare statement in Visual Basic is true.

  Returns the error code returned by the last unmanaged function that was called using platform invoke that has the flag set.

  The last error code set by a call to the Win32 SetLastError function.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("This method has been deprecated")
  System.IntPtr `` `` ``

  is exposed for compiler support only.

  Gets a pointer to a runtime-generated function that marshals a call from managed to unmanaged code.

  A pointer to the function that will marshal a call from the parameter to unmanaged code.

  A pointer to the method to marshal. A pointer to the method signature. The number of bytes in .
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Reflection.MemberInfo `` `` `` To be added: an object of type 'Type' To be added: an object of type 'int' To be added: an object of type 'ComMemberType&' To be added To be added: an object of type 'Reflection.MemberInfo' To be added
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The parameter must point to sufficient memory to store the resulting VARIANT. Also, the implementation of this method calls VariantInit on the raw memory that the parameter points to.

  Converts an object to a COM VARIANT.

  The object for which to get a COM VARIANT. A pointer to receive the VARIANT that corresponds to the parameter.
- Method
  4.0.0.0
  System.Void `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  This method wraps IUnknown in a managed object. This has the effect of incrementing the reference count of the COM component. The reference count will be decremented when the runtime performs garbage collection on the managed object that represents the COM object.

  The parameter represents an IUnknown interface pointer; however, because all COM interfaces derive directly or indirectly from IUnknown, you can pass any COM interface to this method. The object returned by is a Runtime Callable Wrapper, which the common language runtime manages as it does any other managed object. The type of this wrapper is often a generic System.__ComObject type, which is a hidden type used when the wrapper type is ambiguous. You can still make late-bound calls to such a generic type as long as the COM object implements the IDispatch interface. Likewise, you can cast the returned object to an appropriate COM interface.

  For an object to be wrapped with a specific managed class type (and not a generic wrapper type), you must adhere to the following requirements:

  Implement the IProvideClassInfo interface for the COM object.

  Register the containing assembly with the Assembly Registration Tool (Regasm.exe).

  Alternatively, you can avoid these requirements and still get an object that is wrapped with a specific managed class type by using the method.

  Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.

  An object that represents the specified unmanaged COM object.

  A pointer to the IUnknown interface.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  returns a managed object that corresponds to a raw pointer to an unmanaged VARIANT type. The interop marshaler performs the identical transformation when exposing a VARIANT type to managed code.

  provides the opposite functionality of .

  When the VARIANT type is VT_ERROR, returns an object of type Int32 instead of UInt32.

  Converts a COM VARIANT to an object.

  An object that corresponds to the parameter.

  A pointer to a COM VARIANT.
- Method
  4.0.0.0
  T ``

  returns a managed object of type that corresponds to a raw pointer to an unmanaged VARIANT type. The interop marshaler performs the identical transformation when exposing a VARIANT type to managed code.

  provides the opposite functionality of .

  [Supported in the .NET Framework 4.5.1 only]

  Converts a COM VARIANT to an object of a specified type.

  An object of the specified type that corresponds to the parameter.

  A pointer to a COM VARIANT. The type to which to convert the COM VARIANT.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object[] `` ``

  returns an array of managed objects that corresponds to a raw pointer to a C-style array of unmanaged VARIANT types. The interop marshaler performs the identical transformation when exposing a VARIANT type to managed code. The method returns an empty array when the parameter is 0.

  The object array (the return value) gets garbage collected as usual. The unmanaged input array or individual VARIANTs in the input array are not freed. Therefore it is your responsibility to free them as appropriate.

  Converts an array of COM VARIANTs to an array of objects.

  An object array that corresponds to .

  A pointer to the first element of an array of COM VARIANTs. The count of COM VARIANTs in .
- Method
  4.0.0.0
  T[] `` ``

  returns an array of that corresponds to a raw pointer to a C-style array of unmanaged VARIANT types. The interop marshaler performs the identical transformation when exposing a VARIANT type to managed code. The method returns an empty array when the parameter is 0.

  The returned array is garbage-collected as usual. The unmanaged input array or individual VARIANTs in the input array are not freed. Therefore, it is your responsibility to free them as appropriate.

  [Supported in the .NET Framework 4.5.1 only]

  Converts an array of COM VARIANTs to an array of a specified type.

  An array of objects that corresponds to .

  A pointer to the first element of an array of COM VARIANTs. The count of COM VARIANTs in . The type of the array to return.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method returns the zero-based v-table number for an interface or a class. When used on a class, the slot number that is returned refers to the class interface for the class. If the class interface is auto-dispatch, this method always returns -1 to indicate that the dispatch-only interface does not expose a v-table to managed clients. You can use and in conjunction with to pass slots within a specified range. For additional information, see Introducing the Class Interface.

  Gets the first slot in the virtual function table (v-table or VTBL) that contains user-defined methods.

  The first VTBL slot that contains user-defined methods. The first slot is 3 if the interface is based on IUnknown, and 7 if the interface is based on IDispatch.

  A type that represents an interface.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("This method has been deprecated")
  System.Threading.Thread ``

  Fiber cookies are opaque tokens that are used by the host when alerting the common language runtime to its fiber-scheduling decisions. They consist of a stack and register context.

  Converts a fiber cookie into the corresponding instance.

  A thread that corresponds to the parameter.

  An integer that represents a fiber cookie.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` ``

  The parameter must be either a COM-imported type or a subtype of a COM-imported type. In addition, must be a type whose metadata was imported by the Tlbimp.exe (Type Library Importer) tool. This type must be a class and not an associated coclass interface, which carries the name of the COM class. For example, if Tlbimp.exe imports Myclass as a class called MyclassClass and as a coclass interface called Myclass, you must use MyclassClass (not Myclass) with this method. For additional information about imported classes and coclass interfaces, see [<topic://cpcontlbimptypeconversion>].

  If an object has already been obtained for the parameter, is ignored and the existing object is returned. represents an IUnknown interface pointer; however, because all COM interfaces derive directly or indirectly from IUnknown, you can pass any COM interface to this method. The object returned by is a Runtime Callable Wrapper (RCW), which the common language runtime manages as it does any other managed object.

  Returns a managed object of a specified type that represents a COM object.

  An instance of the class corresponding to the object that represents the requested unmanaged COM object.

  A pointer to the IUnknown interface of the unmanaged object. The type of the requested managed class.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Type ``

  returns a instance that is based on the original type. You can apply the to replace standard interop marshaling behavior with this custom marshaler. The Tlbimp.exe (Type Library Importer) tool uses the custom marshaler to translate ITypeInfo parameters to parameters. However, if you obtain an ITypeInfo interface by some means other than Tlbimp.exe, you can use to manually perform the same translation.

  Converts an unmanaged ITypeInfo object into a managed object.

  A managed type that represents the unmanaged ITypeInfo object.

  The ITypeInfo interface to marshal.
- Method
  2.0.0.0
  4.0.0.0
  System.String ``

  You can also retrieve the name of the type represented by an ITypeInfo by calling the method and passing -1 for its first parameter.

  Retrieves the name of the type represented by an ITypeInfo object.

  The name of the type that the parameter points to.

  An object that represents an ITypeInfo pointer.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete
  System.String ``

  You can also retrieve the name of the type represented by an ITypeInfo object by calling the method and passing -1 for its first parameter.

  Retrieves the name of the type represented by an ITypeInfo object.

  The name of the type that the parameter points to.

  An object that represents an ITypeInfo pointer.
- Method
  2.0.0.0
  4.0.0.0
  System.Guid ``

  extracts the LIBID directly from an existing type library. This action differs from that of the method, which calculates what the LIBID should be based on the current assembly.

  For more information about library identifiers, see Exported Assembly Conversion.

  Retrieves the library identifier (LIBID) of a type library.

  The LIBID of the specified type library.

  The type library whose LIBID is to be retrieved.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete
  System.Guid ``

  extracts the LIBID directly from an existing type library. This action differs from that of the method, which calculates what the LIBID should be based on the current assembly.

  For more information about library identifiers, see Exported Assembly Conversion.

  Retrieves the library identifier (LIBID) of a type library.

  The LIBID of the type library that the parameter points to.

  The type library whose LIBID is to be retrieved.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Guid ``

  When assemblies are exported to type libraries, the type library is assigned a LIBID. You can set the LIBID explicitly by applying the at the assembly level, or it can be generated automatically. The Tlbimp.exe (Type Library Importer) tool calculates a LIBID value based on the identity of the assembly. returns the LIBID that is associated with the , if the attribute is applied. Otherwise, returns the calculated value. Alternatively, you can use the method to extract the actual LIBID from an existing type library.

  See the Exported Assembly Conversion topic for more information about library identifiers.

  Retrieves the library identifier (LIBID) that is assigned to a type library when it was exported from the specified assembly.

  The LIBID that is assigned to a type library when it is exported from the specified assembly.

  The assembly from which the type library was exported.
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 `` To be added.

  Retrieves the LCID of a type library.

  The LCID of the type library that the parameter points to.

  The type library whose LCID is to be retrieved.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete
  System.Int32 `` To be added

  Retrieves the LCID of a type library.

  The LCID of the type library that the parameter points to.

  The type library whose LCID is to be retrieved.
- Method
  2.0.0.0
  4.0.0.0
  System.String ``

  The name returned by this method is the identifier used with the library statement, such as ADODB for the Microsoft ADO type library. The name is not a file name.

  You can also retrieve the type library name by calling the method and passing -1 for its first parameter.

  Retrieves the name of a type library.

  The name of the type library that the parameter points to.

  The type library whose name is to be retrieved.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete
  System.String ``

  The name returned by this method is the identifier used with the library statement, such as ADODB for the Microsoft ADO type library. The name is not a file name.

  You can also retrieve the type library name by calling the method and passing -1 for its first parameter.

  Retrieves the name of a type library.

  The name of the type library that the parameter points to.

  The type library whose name is to be retrieved.
- Method
  2.0.0.0
  4.0.0.0
  System.Void `` `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Object ``

  The method ensures that you receive a unique RCW, because it does not match an IUnknown pointer to an existing object. Use this method when you have to create a unique RCW that is not impacted by other code that calls the method.

  Creates a unique Runtime Callable Wrapper (RCW) object for a given IUnknown interface.

  A unique RCW for the specified IUnknown interface.

  A managed pointer to an IUnknown interface.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete("This method has been deprecated")
  System.IntPtr `` `` ``

  is exposed for compiler support only.

  Gets a pointer to a runtime-generated function that marshals a call from unmanaged to managed code.

  A pointer to a function that will marshal a call from to managed code.

  A pointer to the method to marshal. A pointer to the method signature. The number of bytes in .
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  returns true if the class type of the instance is attributed with or if it derives directly or indirectly from a class attributed with . The Tlbimp.exe (Type Library Importer) tool applies this attribute for you when it imports a type library.

  Two other methods also determine whether a specified object represents a COM object, but the requirements for returning true differ from this method's requirements. returns true if the class (or interface) is attributed with directly; it does not return true for derived types. returns true if the type is attributed with or derives from a type with the same GUID.

  Indicates whether a specified object represents a COM object.

  true if the parameter is a COM type; otherwise, false.

  The object to check.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  enables you to check for COM visibility in one step. Types that are not visible cannot be used from COM. A type is visible if it is public and not hidden with the .

  Indicates whether a type is visible to COM clients.

  true if the type is visible to COM; otherwise, false.

  The type to check for COM visibility.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  The method returns the stack size (in bytes) needed to represent the parameters of a method signature in unmanaged memory.

  Note that the return value of this method is platform-dependent. For example, a signature with a single integer parameter returns a value of 4 on 32-bit platforms and a value of 8 on 64-bit platforms.

  Calculates the number of bytes in unmanaged memory that are required to hold the parameters for the specified method.

  The number of bytes required to represent the method parameters in unmanaged memory.

  The method to be checked.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  provides the offset in terms of the unmanaged structure layout, which does not necessarily correspond to the offset of the managed structure layout. Marshaling the structure can transform the layout and alter the offset. The parameter can be a value type or a formatted reference type (with either a sequential or explicit layout). You can obtain the size of the entire layout by using the method. For additional information, see Default Marshaling for Value Types.

  Beginning with the .NET Framework version 2.0, may expose private fields.

  Returns the field offset of the unmanaged form of the managed class.

  The offset, in bytes, for the parameter within the specified class that is declared by platform invoke.

  A value type or formatted reference type that specifies the managed class. You must apply the to the class. The field within the parameter.
- Method
  4.0.0.0
  System.IntPtr ``

  provides the offset in terms of the unmanaged structure layout, which does not necessarily correspond to the offset of the managed structure layout. Marshaling the structure can transform the layout and alter the offset. The generic type parameter can be a value type or a formatted reference type (with either a sequential or explicit layout). You can obtain the size of the entire layout by using the method. For additional information, see Default Marshaling for Value Types.

  Beginning with the .NET Framework version 2.0, may expose private fields.

  [Supported in the .NET Framework 4.5.1 only]

  Returns the field offset of the unmanaged form of a specified managed class.

  The offset, in bytes, for the parameter within the specified class that is declared by platform invoke.

  The name of the field in the type. A managed value type or formatted reference type. You must apply the attribute to the class.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  Setup tasks provide early initialization and are performed automatically when the target method is invoked. First-time tasks include the following:

  Verifying that the platform invoke metadata is correctly formatted.

  Verifying that all the managed types are valid parameters of platform invoke functions.

  Locating and loading the unmanaged DLL into the process.

  Locating the entry point in the process.

  Calling on a method outside of platform invoke has no effect. To execute setup tasks on all platform invoke methods in a type, use .

  Executes one-time method setup tasks without calling the method.

  The method to be checked.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method invokes on every method for a given type. executes one-time method setup tasks without calling each method. You can use only for platform invoke calls.

  Performs a pre-link check for all methods on a class.

  The class whose methods are to be checked.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the and methods.

  Copies all characters up to the first null character from an unmanaged ANSI string to a managed , and widens each ANSI character to Unicode.

  A managed string that holds a copy of the unmanaged ANSI string. If is null, the method returns a null string.

  The address of the first character of the unmanaged string.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` ``

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the and methods.

  Allocates a managed , copies a specified number of characters from an unmanaged ANSI string into it, and widens each ANSI character to Unicode.

  A managed string that holds a copy of the native ANSI string if the value of the parameter is not null; otherwise, this method returns null.

  The address of the first character of the unmanaged string. The byte count of the input string to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  If the current platform is Unicode, each ANSI character is widened to a Unicode character and this method calls . Otherwise, this method calls .

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. provides the opposite functionality of the and methods.

  Allocates a managed and copies all characters up to the first null character from a string stored in unmanaged memory into it.

  A managed string that holds a copy of the unmanaged string if the value of the parameter is not null; otherwise, this method returns null.

  For Unicode platforms, the address of the first Unicode character.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` ``

  On Unicode platforms, this method calls ; on ANSI platforms, it calls . No transformations are done before these methods are called.

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. provides the opposite functionality of and .

  Allocates a managed and copies the specified number of characters from a string stored in unmanaged memory into it.

  A managed string that holds a copy of the native string if the value of the parameter is not null; otherwise, this method returns null.

  For Unicode platforms, the address of the first Unicode character. The number of characters to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  Call this method only on strings that were allocated with the unmanaged SysAllocString and SysAllocStringLen functions.

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the method.

  Allocates a managed and copies a BSTR string stored in unmanaged memory into it.

  A managed string that holds a copy of the unmanaged string if the value of the parameter is not null; otherwise, this method returns null.

  The address of the first character of the unmanaged string.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the and methods.

  Allocates a managed and copies all characters up to the first null character from an unmanaged Unicode string into it.

  A managed string that holds a copy of the unmanaged string if the value of the parameter is not null; otherwise, this method returns null.

  The address of the first character of the unmanaged string.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` ``

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the and methods.

  Allocates a managed and copies a specified number of characters from an unmanaged Unicode string into it.

  A managed string that holds a copy of the unmanaged string if the value of the parameter is not null; otherwise, this method returns null.

  The address of the first character of the unmanaged string. The number of Unicode characters to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.Void `` ``

  is often necessary in COM interop and platform invoke when structure parameters are represented as an value. You cannot use this overload method with value types.

  Marshals data from an unmanaged block of memory to a managed object.

  A pointer to an unmanaged block of memory. The object to which the data is to be copied. This must be an instance of a formatted class.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.Object `` ``

  is often necessary in COM interop and platform invoke when structure parameters are represented as an value. You can pass a value type to this overload method. In this case, the returned object is a boxed instance.

  Marshals data from an unmanaged block of memory to a newly allocated managed object of the specified type.

  A managed object containing the data pointed to by the parameter.

  A pointer to an unmanaged block of memory. The type of object to be created. This object must represent a formatted class or a structure.
- Method
  4.0.0.0
  T ``

  is often necessary in COM interop and platform invoke when structure parameters are represented as values. You can pass a value type to this method overload.

  [Supported in the .NET Framework 4.5.1 only]

  Marshals data from an unmanaged block of memory to a newly allocated managed object of the type specified by a generic type parameter.

  A managed object that contains the data that the parameter points to.

  A pointer to an unmanaged block of memory. The type of the object to which the data is to be copied. This must be a formatted class or a structure.
- Method
  4.0.0.0
  System.Void `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` `` To be added: an object of type 'IntPtr' To be added: an object of type 'Guid&' To be added: an object of type 'IntPtr&' To be added To be added: an object of type 'int' To be added
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Byte ``

  has an implied offset of 0. This method enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a single byte from unmanaged memory.

  The byte read from unmanaged memory.

  The address in unmanaged memory from which to read.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Byte `` ``

  enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a single byte at a given offset (or index) from unmanaged memory.

  The byte read from unmanaged memory at the given offset.

  The base address in unmanaged memory from which to read. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Security.SuppressUnmanagedCodeSecurity
  System.Byte `` ``

  enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a single byte at a given offset (or index) from unmanaged memory.

  The byte read from unmanaged memory at the given offset.

  The base address in unmanaged memory of the source object. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 ``

  has an implied offset of 0. This method enables direct interaction with an unmanaged C-style Int16 array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 16-bit signed integer from unmanaged memory.

  The 16-bit signed integer read from unmanaged memory.

  The address in unmanaged memory from which to read.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 16-bit signed integer at a given offset from unmanaged memory.

  The 16-bit signed integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory from which to read. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Security.SuppressUnmanagedCodeSecurity
  System.Int16 `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 16-bit signed integer at a given offset from unmanaged memory.

  The 16-bit signed integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory of the source object. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Int32 ``

  has an implied offset of 0. This method enables direct interaction with an unmanaged C-style Int32 array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 32-bit signed integer from unmanaged memory.

  The 32-bit signed integer read from unmanaged memory.

  The address in unmanaged memory from which to read.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Int32 `` ``

  enables direct interaction with an unmanaged 32-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 32-bit signed integer at a given offset from unmanaged memory.

  The 32-bit signed integer read from unmanaged memory.

  The base address in unmanaged memory from which to read. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Security.SuppressUnmanagedCodeSecurity
  System.Int32 `` ``

  enables direct interaction with an unmanaged 32-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 32-bit signed integer at a given offset from unmanaged memory.

  The 32-bit signed integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory of the source object. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Int64 ``

  has an implied offset of 0. This method enables direct interaction with an unmanaged C-style Int64 array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 64-bit signed integer from unmanaged memory.

  The 64-bit signed integer read from unmanaged memory.

  The address in unmanaged memory from which to read.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 `` ``

  enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 64-bit signed integer at a given offset from unmanaged memory.

  The 64-bit signed integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory from which to read. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Security.SuppressUnmanagedCodeSecurity
  System.Int64 `` ``

  enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a 64-bit signed integer at a given offset from unmanaged memory.

  The 64-bit signed integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory of the source object. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.IntPtr ``

  has an implied offset of 0. This method enables direct interaction with an unmanaged C-style IntPtr array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a processor native-sized integer from unmanaged memory.

  The integer read from unmanaged memory. A 32 bit integer is returned on 32 bit machines and a 64 bit integer is returned on 64 bit machines.

  The address in unmanaged memory from which to read.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.IntPtr `` ``

  enables direct interaction with an unmanaged C-style IntPtr array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a processor native sized integer at a given offset from unmanaged memory.

  The integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory from which to read. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.IntPtr `` ``

  enables direct interaction with an unmanaged C-style IntPtr array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before reading its element values.

  Reading from unaligned memory locations is supported.

  Reads a processor native sized integer from unmanaged memory.

  The integer read from unmanaged memory at the given offset.

  The base address in unmanaged memory of the source object. An additional byte offset, which is added to the parameter before reading.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  is one of two memory reallocation methods in the class. ( is the other.) The beginning of the reallocated memory content is the same as the original content; however, the entire memory block can be in a different location. This method exposes the COM CoTaskMemRealloc function, which is referred to as the COM task memory allocator.

  Resizes a block of memory previously allocated with .

  An integer representing the address of the reallocated block of memory. This memory must be released with .

  A pointer to memory allocated with . The new size of the allocated block.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  is one of two memory reallocation API methods in the class. ( is the other.)

  This method exposes the Win32 GlobalReAlloc function from Kernel32.dll. The returned pointer can differ from the original. If it is different, the contents of the original memory block have been copied to the new block, and the original memory block has been freed.

  Resizes a block of memory previously allocated with .

  A pointer to the reallocated memory. This memory must be released using .

  A pointer to memory allocated with . The new size of the allocated block. This is not a pointer; it is the byte count you are requesting, cast to type . If you pass a pointer, it is treated as a size.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)
  System.Int32 ``

  The common language runtime manages the reference count of a COM object for you, making it unnecessary to use this method directly. Use this value only for testing purposes. In rare cases, such as testing a custom marshaler, you might find it necessary to manipulate an object's lifetime manually. Only programs that call should call . Calling after the reference count has reached zero causes undefined behavior.

  You can call , , or to obtain an value that represents a IUnknown interface pointer to release. You can also use these methods and the method on managed objects to release the COM interfaces represented by the managed object's COM Callable Wrapper.

  Decrements the reference count on the specified interface.

  The new value of the reference count on the interface specified by the parameter.

  The interface to release.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method is used to explicitly control the lifetime of a COM object used from managed code. You should use this method to free the underlying COM object that holds references to resources in a timely manner or when objects must be freed in a specific order.

  Every time a COM interface pointer enters the common language runtime (CLR), it is wrapped in an RCW.

  The RCW has a reference count that is incremented every time a COM interface pointer is mapped to it. The method decrements the reference count of an RCW. When the reference count reaches zero, the runtime releases all its references on the unmanaged COM object, and throws a if you attempt to use the object further. If the same COM interface is passed more than one time from unmanaged to managed code, the reference count on the wrapper is incremented every time, and calling returns the number of remaining references.

  This method enables you to force an RCW reference count release so that it occurs precisely when you want it to. However, improper use of may cause your application to fail, or may cause an access violation.

  Consider a scenario in which managed code in an application domain is holding onto an RCW that represents a COM component. If you call the method on the RCW, the managed code will be unable to access the RCW and will raise an exception.

  A more serious error may occur if a call to the RCW is executing when the RCW is released. In this case, there is a good chance that the thread making the call will cause an access violation. However, process memory may become corrupted, and the process may continue to run until it fails for reasons that are very difficult to debug.

  This risk is compounded when the COM component that is being used is a singleton, for the following reason: The CLR activates COM components by calling the COM CoCreateInstance function, which returns the same interface pointer every time it is called for singleton COM components. Thus, separate and independent pieces of managed code in an application domain can be using the same RCW for a singleton COM component, and if either one calls the method on the COM component, the other will be broken.

  Therefore, use the only if it is absolutely required. If you want to call this method to ensure that a COM component is released at a determined time, consider using the method instead. will release the underlying COM component regardless of how many times it has re-entered the CLR. The internal reference count of the RCW is incremented by one every time the COM component re-enters the CLR. Therefore, you could call the method in a loop until the value returned is zero. This achieves the same result as the method.

  Decrements the reference count of the specified Runtime Callable Wrapper (RCW) associated with the specified COM object.

  The new value of the reference count of the RCW associated with . This value is typically zero since the RCW keeps just one reference to the wrapped COM object regardless of the number of managed clients calling it.

  The COM object to release.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Obsolete
  System.Void To be added

  Releases the thread cache.

- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  The method is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the BSTR when finished by calling the method.

  Allocates a BSTR and copies the contents of a managed object into it.

  The address, in unmanaged memory, where the parameter was copied to, or 0 if a null object was supplied.

  The managed object to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  The method is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . The characters of the string are copied as ANSI characters.

  Copies the contents of a managed object to a block of memory allocated from the unmanaged COM task allocator.

  The address, in unmanaged memory, where the parameter was copied to, or 0 if a null object was supplied.

  The managed object to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  The method is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling the method. The characters of the string are copied as Unicode characters.

  Copies the contents of a managed object to a block of memory allocated from the unmanaged COM task allocator.

  The address, in unmanaged memory, where the parameter was copied to, or 0 if a null object was supplied.

  The managed object to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  The method is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling the method.

  Copies the contents of a managed into unmanaged memory, converting into ANSI format as it copies.

  The address, in unmanaged memory, to where the parameter was copied, or 0 if a null object was supplied.

  The managed object to copy.
- Method
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  The method is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling the method.

  Copies the contents of a managed object into unmanaged memory.

  The address, in unmanaged memory, where was copied, or 0 if is a object whose length is 0.

  The managed object to copy.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` ``

  All COM objects wrapped in a Runtime Callable Wrapper (RCW) have an associated hash table, to which adds data. retrieves data from the hash table. You should never have to call either method from your code.

  Sets data referenced by the specified key in the specified COM object.

  true if the data was set successfully; otherwise, false.

  The COM object in which to store the data. The key in the internal hash table of the COM object in which to store the data. The data to set.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(true)
  System.Int32 ``

  This method accepts an instance of a structure, which can be a reference type or a boxed value type. The layout must be sequential or explicit.

  The size returned is the size of the unmanaged object. The unmanaged and managed sizes of an object can differ. For character types, the size is affected by the value applied to that class.

  You can use the method to determine how much unmanaged memory to allocate using the and methods.

  Returns the unmanaged size of an object in bytes.

  The size of the specified object in unmanaged code.

  The object whose size is to be returned.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  You can use this method when you do not have a structure. The layout must be sequential or explicit.

  The size returned is the size of the unmanaged type. The unmanaged and managed sizes of an object can differ. For character types, the size is affected by the value applied to that class.

  Returns the size of an unmanaged type in bytes.

  The size of the specified type in unmanaged code.

  The type whose size is to be returned.
- Method
  4.0.0.0
  System.Int32

  You can use this method when you do not have a structure. The layout must be sequential or explicit.

  The size returned is the size of the unmanaged type. The unmanaged and managed sizes of an object can differ. For character types, the size is affected by the value applied to that class.

  [Supported in the .NET Framework 4.5.1 only]

  Returns the size of an unmanaged type in bytes.

  The size, in bytes, of the type that is specified by the generic type parameter.

  The type whose size is to be returned.
- Method
  4.0.0.0
  System.Int32 `` To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the BSTR when finished by calling . This method provides the opposite functionality of .

  Allocates a BSTR and copies the contents of a managed into it.

  An unmanaged pointer to the BSTR, or 0 if is null.

  The managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . This method provides the opposite functionality of . The characters of the string are copied as ANSI characters.

  Copies the contents of a managed to a block of memory allocated from the unmanaged COM task allocator.

  An integer representing a pointer to the block of memory allocated for the string, or 0 if is null.

  A managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . This method provides the opposite functionality of .

  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 98, the characters are copied as ANSI characters. On Windows NT 4.0, Windows 2000, Windows XP, and the Windows Server 2003 family, the characters are copied as Unicode characters.

  Copies the contents of a managed to a block of memory allocated from the unmanaged COM task allocator.

  The allocated memory block, or 0 if is null.

  A managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . This method provides the opposite functionality of . The characters of the string are copied as Unicode characters.

  Copies the contents of a managed to a block of memory allocated from the unmanaged COM task allocator.

  An integer representing a pointer to the block of memory allocated for the string, or 0 if s is null.

  A managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . provides the opposite functionality of .

  This method copies embedded null characters, and includes a terminating null character.

  Copies the contents of a managed into unmanaged memory, converting into ANSI format as it copies.

  The address, in unmanaged memory, to where was copied, or 0 if is null.

  A managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . This method provides the opposite functionality of .

  This method copies embedded null characters, and includes a terminating null character.

  Copies the contents of a managed into unmanaged memory, converting into ANSI format if required.

  The address, in unmanaged memory, to where the string was copied, or 0 if is null.

  A managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr ``

  is useful for custom marshaling or for use when mixing managed and unmanaged code. Because this method allocates the unmanaged memory required for a string, always free the memory by calling . This method provides the opposite functionality of .

  This method copies embedded null characters, and includes a terminating null character.

  Copies the contents of a managed into unmanaged memory.

  The address, in unmanaged memory, to where the was copied, or 0 if is null.

  A managed string to be copied.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)
  System.Runtime.InteropServices.ComVisible(true)
  System.Void `` `` ``

  If is a value type, it can be boxed or unboxed. If it is boxed, it is unboxed before copying.

  A formatted class is a reference type whose layout is specified by the attribute, as either or .

  copies the contents of to the pre-allocated block of memory that the parameter points to. If contains reference types that marshal to COM interface pointers (interfaces, classes without layout, and ), the managed objects are kept alive with reference counts. All other reference types (for example, strings and arrays) are marshaled to copies. To release these managed or unmanaged objects, you must call the method before you free the memory block.

  If you use the method to copy a different instance to the memory block at a later time, specify true for to remove reference counts for reference types in the previous instance. Otherwise, the managed reference types and unmanaged copies are effectively leaked.

  The overall pattern for using is as follows:

  On the first call to the method after a memory block has been allocated, must be false, because there are no contents to clear.

  Specify true for only if the block contains valid data.

  If you copy a different instance to the memory block, and the object contains reference types, must be true to free reference types in the old contents.

  If the object contains reference types, you must call the method before you free the memory block.

  To pin an existing structure instead of copying it, use the type to create a pinned handle for the structure. For details on how to pin, see Copying and Pinning.

  Marshals data from a managed object to an unmanaged block of memory.

  A managed object that holds the data to be marshaled. This object must be a structure or an instance of a formatted class. A pointer to an unmanaged block of memory, which must be allocated before this method is called. true to call the method on the parameter before this method copies the data. The block must contain valid data. Note that passing false when the memory block already contains data can lead to a memory leak.
- Method
  4.0.0.0
  System.Void `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 1 To be added

  Represents the default character size on the system; the default is 2 for Unicode systems and 1 for ANSI systems. This field is read-only.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 2 To be added

  Represents the maximum size of a double byte character set (DBCS) size, in bytes, for the current operating system. This field is read-only.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  This method creates an exception object for the specified failure HRESULT. If the HRESULT is 0 or positive (a success code), the method returns without creating or throwing an exception.

  Note that the method returns an exception based on the IErrorInfo of the current thread if one is set. When this happens, the parameter is ignored.

  Some failure HRESULTs map to defined exceptions, whereas others do not. If the HRESULT maps to a defined exception, creates an instance of the exception and throws it. Otherwise, it creates an instance of , initializes the error code field with the HRESULT, and throws that exception. When is invoked, it attempts to retrieve extra information regarding the error by using the unmanaged GetErrorInfo function.

  For the mapping from each HRESULT to its comparable exception class in the .NET Framework, see How to: Map HRESULTs and Exceptions.

  Occasionally, might return an exception from a previous COM call. In this case, you can use the following workaround and pass IntPtr(-1) as the second parameter (errorInfo):

  `[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static void ThrowExceptionForHR(int errorCode,IntPtr errorInfo)`

  Throws an exception with a specific failure HRESULT value.

  The HRESULT corresponding to the desired exception.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  This method creates an exception object for the specified failure HRESULT. If the HRESULT is 0 or positive (a success code), the method returns without creating or throwing an exception.

  The method releases the parameter, decreasing the COM reference count of the IErrorInfo interface.

  Note that the method returns an exception based on the IErrorInfo interface of the current thread if one is set. When this happens, the parameter is ignored.

  Some failure HRESULTs map to defined exceptions, whereas others do not. If the HRESULT maps to a defined exception, creates an instance of the exception and throws it. Otherwise, it creates an instance of , initializes the error code field with the HRESULT, and throws that exception. The parameter is used to retrieve extra information regarding the error.

  For the mapping from each HRESULT to its comparable exception class in the .NET Framework, see How to: Map HRESULTs and Exceptions.

  Throws an exception with a specific failure HRESULT, based on the specified IErrorInfo interface.

  The HRESULT corresponding to the desired exception. A pointer to the IErrorInfo interface that provides more information about the error. You can specify IntPtr(0) to use the current IErrorInfo interface, or IntPtr(-1) to ignore the current IErrorInfo interface and construct the exception just from the error code.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IntPtr `` ``

  The array must be pinned using a before it is passed to this method. For maximum performance, this method does not validate the array passed to it; this can result in unexpected behavior.

  Gets the address of the element at the specified index inside the specified array.

  The address of inside .

  The array that contains the desired element. The index in the parameter of the desired element.
- Method
  4.0.0.0
  System.IntPtr `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writes a single byte value to unmanaged memory.

  The address in unmanaged memory to write to. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writes a single byte value to unmanaged memory at a specified offset.

  The base address in unmanaged memory to write to. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Security.SuppressUnmanagedCodeSecurity
  System.Void `` `` ``

  enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writes a single byte value to unmanaged memory at a specified offset.

  The base address in unmanaged memory of the target object. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a character as a 16-bit integer value to unmanaged memory.

  The address in unmanaged memory to write to. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 16-bit integer value to unmanaged memory.

  The address in unmanaged memory to write to. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

  The base address in the native heap to write to. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 16-bit signed integer value into unmanaged memory at a specified offset.

  The base address in unmanaged memory to write to. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

  The base address in unmanaged memory of the target object. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Security.SuppressUnmanagedCodeSecurity
  System.Void `` `` ``

  enables direct interaction with an unmanaged 16-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 16-bit signed integer value to unmanaged memory at a specified offset.

  The base address in unmanaged memory of the target object. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  enables direct interaction with an unmanaged 32-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 32-bit signed integer value to unmanaged memory.

  The address in unmanaged memory to write to. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged 32-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 32-bit signed integer value into unmanaged memory at a specified offset.

  The base address in unmanaged memory to write to. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Security.SuppressUnmanagedCodeSecurity
  System.Void `` `` ``

  enables direct interaction with an unmanaged 32-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 32-bit signed integer value to unmanaged memory at a specified offset.

  The base address in unmanaged memory of the target object. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 64-bit signed integer value to unmanaged memory.

  The address in unmanaged memory to write to. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 64-bit signed integer value to unmanaged memory at a specified offset.

  The base address in unmanaged memory to write. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Security.SuppressUnmanagedCodeSecurity
  System.Void `` `` ``

  enables direct interaction with an unmanaged 64-bit signed array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a 64-bit signed integer value to unmanaged memory at a specified offset.

  The base address in unmanaged memory of the target object. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  enables direct interaction with an unmanaged C-style IntPtr array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a processor native sized integer value into unmanaged memory.

  The address in unmanaged memory to write to. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  This method writes a 32 bit integer on 32 bit systems, and a 64 bit integer on 64 bit systems.

  enables direct interaction with an unmanaged C-style IntPtr array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a processor native-sized integer value to unmanaged memory at a specified offset.

  The base address in unmanaged memory to write to. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  enables direct interaction with an unmanaged C-style byte array, eliminating the expense of copying an entire unmanaged array (using ) to a separate managed array before setting its element values.

  Writing to unaligned memory locations is supported.

  Writes a processor native sized integer value to unmanaged memory.

  The base address in unmanaged memory of the target object. An additional byte offset, which is added to the parameter before writing. The value to write.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method first sets the contents of the BSTR to zero, and then frees the BSTR.

  Frees a BSTR pointer that was allocated using the method.

  The address of the BSTR to free.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method first zeros out and then frees unmanaged memory that was allocated using the method.

  Frees an unmanaged string pointer that was allocated using the method.

  The address of the unmanaged string to free.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method first zeros out and then frees unmanaged memory that was allocated using the method.

  Frees an unmanaged string pointer that was allocated using the method.

  The address of the unmanaged string to free.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method first zeros out and then frees unmanaged memory that was allocated using the method.

  Frees an unmanaged string pointer that was allocated using the method.

  The address of the unmanaged string to free.
- Method
  2.0.0.0
  4.0.0.0
  System.Void ``

  The method first zeros out and then frees unmanaged memory that was allocated using the method.

  Frees an unmanaged string pointer that was allocated using the method.

  The address of the unmanaged string to free.