主程序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();                }

解决方案 »

  1.   

    这关WCF鸟事,完全是Visual Studio中的项目配置问题。
    点击你用想到创建的WCF类库项目,属性-->调试,里面有个命令行参数,清空即可。
      

  2.   

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

  3.   

    这个是不启动WCFTestClient客户端。
      

  4.   


    这个说到点子上了,谢谢了。主要就是想把这个host托管禁用,因为代码处理了,否则会争用端口。WCF服务类库项目-属性设置--WCF选项
    --“调试同一个解决方案另一个项目时启用WCF服务主机”,复选框去掉就好了。