Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

Marshal.GetUniqueObjectForIUnknown Method

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

Namespace:  System.Runtime.InteropServices
Assemblies:   System.Runtime.InteropServices (in System.Runtime.InteropServices.dll)
  mscorlib (in mscorlib.dll)

public static Object GetUniqueObjectForIUnknown(
	IntPtr unknown
)

Parameters

unknown
Type: System.IntPtr

A managed pointer to an IUnknown interface.

Return Value

Type: System.Object
A unique RCW for the specified IUnknown interface.

The GetUniqueObjectForIUnknown 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 ReleaseComObject method.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library

  • SecurityCriticalAttribute 

    requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Show:
© 2015 Microsoft