public sealed class WCFFactory<TChannel> : ChannelFactory<TChannel>
    {
        public static WCFFactory<TChannel> GetFactorty()
        {
            WSHttpBinding binding = new WSHttpBinding();
            EndpointAddress address = new EndpointAddress(new Uri(string.Format("http://{0}/Bll/",ConfigurationManager.AppSettings["hostIP"])));
            binding.MaxReceivedMessageSize = 6553600;
            binding.MaxBufferPoolSize = 52428800;
            binding.ReaderQuotas.MaxDepth = 3200;
            binding.ReaderQuotas.MaxStringContentLength = 819200;
            binding.ReaderQuotas.MaxArrayLength = 16384;
            binding.ReaderQuotas.MaxBytesPerRead = 409600;
            binding.ReaderQuotas.MaxNameTableCharCount = 16384;

            ContractDescription description = ContractDescription.GetContract(typeof(TChannel));

            ServiceEndpoint endpoint = new ServiceEndpoint(description, binding, address);
            return new WCFFactory<TChannel>(endpoint);
        }

        private WCFFactory(ServiceEndpoint endpoint)
            : base(endpoint)
        {

        }
    }
客户端调用
using (WCFFactory<IEngine> ChannelFactory = Factory.WCFFactory<IEngine>.GetFactorty())
            {
                IEngine proxy = ChannelFactory.CreateChannel();
                Console.WriteLine(proxy.GetHTMLByArticle("1"));
                Console.ReadLine();

            }
这样就可以不用在config文件里每次都去修改了

  


 

 public sealed class WCFFactory<TChannel> : ChannelFactory<TChannel>     {         public static WCFFactory<TChannel> GetFactorty()         {             WSHttpBinding binding = new