RemotingGate.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections;
  3. using System.Runtime.Remoting;
  4. using System.Runtime.Remoting.Channels;
  5. using System.Runtime.Remoting.Channels.Tcp;
  6. using System.Configuration;
  7. using System.Runtime.Serialization.Formatters;
  8. using Core.Mes.ServerFrameWork;
  9. namespace Core.Mes.ServerManager
  10. {
  11. public class RemotingGate
  12. {
  13. public RemotingGate()
  14. {
  15. StartServer();
  16. }
  17. public void StartServer()
  18. {
  19. try
  20. {
  21. IDictionary props = new Hashtable();
  22. props["port"] = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings["ServerPort"].Value.ToString();
  23. RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
  24. ChannelServices.RegisterChannel(new TcpChannel(Convert.ToInt32(props["port"])), false);
  25. }
  26. catch (Exception ex)
  27. {
  28. throw new Exception(ex.Message);
  29. }
  30. }
  31. }
  32. }