Gets an interface pointer identified by the specified moniker.
[Visual Basic]
Public Shared Function BindToMoniker( _
ByVal monikerName As String _
) As Object
[C#]
public static object BindToMoniker(
string monikerName
);
[C++]
public: static Object* BindToMoniker(
String* monikerName
);
[JScript]
public static function BindToMoniker(
monikerName : String
) : Object;
Parameters
- monikerName
- The moniker corresponding to the desired interface pointer.
Return Value
An object containing a reference to the interface pointer identified by the monikerName parameter. A moniker is a name, and in this case, the moniker is defined by an interface.
Exceptions
| Exception Type | Condition |
| COMException | An unrecognized HRESULT was returned by the unmanaged BindToMoniker method. |
Remarks
Marshal.BindToMoniker exposes the BindToMoniker COM API 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 Visual Basic .NET. For additional information about the BindToMoniker COM method, see the MSDN Library.
Note 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.
Example
[Visual Basic, C#] The following example demonstrates how to use the BindToMoniker method with the SOAP moniker, provided by Microsoft Windows XP, to seamlessly access an XML Web service from managed code through COM interop:
[Visual Basic]
Dim translator As Object = Marshal.BindToMoniker( _
"SOAP:wsdl=http://www.xmethods.net/sd/2001/BabelFishService.wsdl")
[C#]
object translator = Marshal.BindToMoniker(
"SOAP:wsdl=http://www.xmethods.net/sd/2001/BabelFishService.wsdl");
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
See Also
Marshal Class | Marshal Members | System.Runtime.InteropServices Namespace