This documentation is archived and is not being maintained.

IChannelCredentials Interface

An interface that allows the setting of certain security features on a service proxy.

Namespace:  System.ServiceModel.ComIntegration
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

'Declaration
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)> _
<GuidAttribute("181b448c-c17c-4b17-ac6d-06699b93198f")> _
Public Interface IChannelCredentials
'Usage
Dim instance As IChannelCredentials

Unmanaged clients use the "service" moniker to access Windows Communication Foundation (WCF) services. These clients are subject to the WCF security model rather than the COM security model. The IChannelCredentials interface is provided to specify channel credentials. This is required because the COM moniker cannot access the managed WCF security object model.

It is not legal to call methods on the IChannelCredentials interface after the channel is created. This is because Windows Communication Foundation (WCF) does not support changing security settings on an already opened channel. When the service moniker client obtains a proxy, the channel is not yet created. Thus, the client must call IChannelCredentials methods prior to invoking the service method. If the client calls an IChannelCredentials method after the service method is invoked, the exception RPC_E_TOO_LATE is thrown.

monString = "service:mexAddress=http://localhost:8000/ServiceModelSamples/Service?wsdl"
    monString = monString + ", address=http://localhost:8000/ServiceModelSamples/Service"
    monString = monString + ", binding=BasicHttpBinding_ICalculator, bindingNamespace=http://Microsoft.ServiceModel.Samples"
    monString = monString + ", contract=ICalculator, contractNamespace=http://Microsoft.ServiceModel.Samples"
     
    Set monikerProxy = GetObject(monString)
    
    'Set the Service Certificate.
    monikerProxy.ChannelCredentials.SetServiceCertificateAuthentication "CurrentUser", "NoCheck", "PeerOrChainTrust"
    monikerProxy.ChannelCredentials.SetDefaultServiceCertificateFromStore "CurrentUser", "TrustedPeople", "FindBySubjectName", "localhost"
    
    'Set the Client Certificate.
    monikerProxy.ChannelCredentials.SetClientCertificateFromStoreByName "CN=client.com", "CurrentUser", "My"
    MsgBox monikerProxy.Add(3, 4)

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: