日期:2014-05-17  浏览次数:20767 次

WCF总是被vs托管,禁用不了找不到在哪设置很烦
主程序Load里面代码启动这些服务,可以vs里运行时那个讨厌的托盘总是显示“你的服务已经被托管啦。。。”。

导致我的代码抢不到端口报错,请问怎么处理,刚了解WCF:
  System.ServiceModel.ServiceHost aServiceHost = null;

  Configuration conf = System.Configuration.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 + ",D8IM.Server.Business");

  if (svcType == null)
  {
  //Lognet.Error("Invalid Service Type " + el.Name + " in configuration file.");
  continue;
  }

  aServiceHost = new System.ServiceModel.ServiceHost(svcType);
  aServiceHost.Open();

  }

------解决方案--------------------
属性里的下面还有个“WCF选项”,里面的勾选也要去掉