Assembly: mscorlib (in mscorlib.dll)
A pointer to the IUnknown interface of the unmanaged object.
The Type of the requested managed class.
Return ValueAn instance of the class corresponding to the Type object that represents the requested unmanaged COM object.
The t parameter must be either a COM-imported type or a subtype of a COM-imported type. In addition, t must be a type whose metadata was imported by the Type Library Importer (Tlbimp.exe). This type must be a class and not an associated coclass interface, which carries the name of the COM class. For example, suppose Tlbimp.exe imports Myclass as a class called MyclassClass and a coclass interface called Myclass. Be sure to use MyclassClass, not Myclass with this method. For additional information about imported classes and coclass interfaces, see Imported Type Conversion.
If an object has already been obtained for the pUnk parameter, then t is ignored and the existing object is returned. pUnk 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 GetTypedObjectForIUnknown is a runtime callable wrapper, which the common language runtime manages as it does any other managed object. For additional information, see Runtime Callable Wrapper.
This method uses SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass user input to Marshal class methods without validation. For important limitations on using the LinkDemand member, see Demand vs. LinkDemand.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.