WCF服务。利用循环,读取配置文件,一次性将所有的服务全部开启
public void hostopen() { Configuration conf = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location); ServiceModelSectionGroup svcmod = (ServiceModelSectionGroup)conf.GetSectionGroup("system.serviceModel"); foreach (ServiceElement el in svcmod.Services.Services) { Type svcType = Type.GetType(el.Name + "," + "Wcf_DaBu_Service"); if (svcType == null) throw new Exception("Invalid Service Type " + el.Name + " in configuration file."); ServiceHost aServiceHost = new ServiceHost(svcType); aServiceHost.Open(); MessageBox.Show(el.Name + "+iiiiiii"); } }
时间: 2025-01-07 07:27:31