What does System.ServiceModel.Clientbase.Open () do?

What does System.ServiceModel.Clientbase.Open () do? I never used it, but came across it in some kind of code. Could this make an exception? If Close () is not called, is that a problem?

+5
source share
2 answers

If you create a proxy for the WCF service, the proxy server works efficiently with ClientBase

An example from my application:

public class DataClient : ClientBase<Classes.IDataService>, Classes.IDataService
{
    public DataClient(string connectToHost)
        : base(new NetTcpBinding(SecurityMode.Transport)
            {
                PortSharingEnabled = true,
                Security = new NetTcpSecurity()
                {
                    Transport = new TcpTransportSecurity()
                    {
                        ClientCredentialType = TcpClientCredentialType.Windows
                    }
                }
            },
            new EndpointAddress(string.Format("net.tcp://{0}:5555/MyService",connectToHost)))
    { }

    #region IDataService Members

    public Classes.Folder GetFolder(string entryID)
    {
        return Channel.GetFolder(entryID);
    }

    public Classes.IItem GetItem(string entryID)
    {
        return Channel.GetItem(entryID);
    }

    #endregion
}

EDIT At your request, I searched google a bit and found this :

Implements ICommunicationObject.Open ()

This led to this :

CommunicationException

The ICommunicationObject could not open and entered the Faulted state.

TimeoutException

- , ICommunicationObject Opened Faulted.

, , , , , " ".

+4

:

: - WCF https://blogs.msdn.microsoft.com/wenlong/2007/10/25/best-practice-always-open-wcf-client-proxy-explicitly-when-it-is-shared/

:

"", - , -. .

? -, -. .NET Reflector, System.ServiceModel.Channels.ServiceChannel.Call :

if (!this.explicitlyOpened)
{
   this.EnsureDisplayUI();
   this.EnsureOpened(rpc.TimeoutHelper.RemainingTime());
}

EnsureOpened, , CallOnceManager.CallOnce. - SyncWait.Wait, . , , - , . , , . .

"" , , . , - .

0

All Articles