public static void StopServer()
 {
     UnregisterObjectWellKnown(ms_tobj);
     UnregisterObjectWellKnown(ms_sobj);
     ms_sobj = null;
     ms_tobj = null;
 }
        public static bool StartHttpServer(int port, TaskTransmissionManager ttm, ref string errormessage)
        {
            try
            {
                RegisterHttpChannel(port);
            }
            catch (Exception e)
            {
                errormessage = e.Message;
                return(false);
            }

            try
            {
                ms_tobj = ttm;
                try
                {
                    RegisterObjectWellKnown(ms_tobj, "TaskTransmissionManager");
                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    return(false);
                }

                ms_sobj = new DomainTransmissionManager();
                try
                {
                    RegisterObjectWellKnown(ms_sobj, "ScriptTransmissionManager");
                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    UnregisterObjectWellKnown(ms_tobj);
                    return(false);
                }
                return(true);
            }
            catch (Exception e)
            {
                errormessage = e.Message;
                UnregisterChannel();
                return(false);
            }
        }
        public static bool StartTcpServer(int port, TaskTransmissionManager ttm, ref string errormessage)
        {
            if (ms_tcpchannel == null)
            {
                errormessage = "缺少必要TCP端口, 请关闭后重新运行服务器程序!";
                return(false);
            }

            try
            {
                ms_tobj = ttm;
                try
                {
                    RegisterObjectWellKnown(ms_tobj, "TaskTransmissionManager");
                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    return(false);
                }

                ms_sobj = new DomainTransmissionManager();
                try
                {
                    RegisterObjectWellKnown(ms_sobj, "DomainTransmissionManager");
                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    UnregisterObjectWellKnown(ms_tobj);
                    return(false);
                }
                return(true);
            }
            catch (Exception e)
            {
                errormessage = e.Message;
                return(false);
            }
        }
        public static bool StartHttpServer(int port, TaskTransmissionManager ttm, ref string errormessage)
        {
            try
            {
                RegisterHttpChannel(port);
            }
            catch (Exception e)
            {
                errormessage = e.Message;
                return false;
            }

            try
            {
                ms_tobj = ttm;
                try
                {
                    RegisterObjectWellKnown(ms_tobj, "TaskTransmissionManager");

                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    return false;
                }

                ms_sobj = new DomainTransmissionManager();
                try
                {
                    RegisterObjectWellKnown(ms_sobj, "ScriptTransmissionManager");
                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    UnregisterObjectWellKnown(ms_tobj);
                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                errormessage = e.Message;
                UnregisterChannel();
                return false;
            }


        }
 public static void StopServer()
 {
     UnregisterObjectWellKnown(ms_tobj);
     UnregisterObjectWellKnown(ms_sobj);
     ms_sobj = null;
     ms_tobj = null;
 }
        public static bool StartTcpServer(int port, TaskTransmissionManager ttm, ref string errormessage)
        {
            if (ms_tcpchannel == null)
            {
                errormessage = "缺少必要TCP端口, 请关闭后重新运行服务器程序!";
                return false;
            }

            try
            {
                ms_tobj = ttm;
                try
                {
                    RegisterObjectWellKnown(ms_tobj, "TaskTransmissionManager");

                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    return false;
                }

                ms_sobj = new DomainTransmissionManager();
                try
                {
                    RegisterObjectWellKnown(ms_sobj, "DomainTransmissionManager");
                }
                catch (Exception e)
                {
                    errormessage = e.Message;
                    UnregisterObjectWellKnown(ms_tobj);
                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                errormessage = e.Message;
                return false;
            }
        }