コード例 #1
0
        public void StopServer()
        {
            try
            {
                if (_hostDiretorSkinner != null)
                {
                    if (_hostDiretorSkinner.State == CommunicationState.Opened)
                    {
                        _hostDiretorSkinner.Close();
                    }

                    _hostDiretorSkinner = null;
                }
            }
            catch (CommunicationException ex)
            {
                EventLog.WriteEntry(ex.Message);

                if (_hostDiretorSkinner != null)
                {
                    _hostDiretorSkinner.Abort();
                }
            }
            finally
            {
                if (_server != null)
                {
                    _server.Dispose();
                    _server = null;
                }
            }
        }
コード例 #2
0
        public void StartServer()
        {
            try
            {
                _server = new DiretorSkinner();

                _hostDiretorSkinner = new ServiceHost(_server);

                Binding tcpBinding = CreateTcpBinding();

                //Use base address as address
                string _hostString = ConfigurationManager.AppSettings["Host"];

                _hostDiretorSkinner.Open();
            }
            catch (CommunicationException ex)
            {
                EventLog.WriteEntry(ex.Message);
            }
        }