当前位置: 代码迷 >> Web Service >> The communication object, System.ServiceModel.ChannelFactory`一[SBBasis.IBasisWCF
  详细解决方案

The communication object, System.ServiceModel.ChannelFactory`一[SBBasis.IBasisWCF

热度:105   发布时间:2016-05-02 02:17:35.0
The communication object, System.ServiceModel.ChannelFactory`1[SBBasis.IBasisWCF
The communication object, System.ServiceModel.ChannelFactory`1[SBBasis.IBasisWCF], cannot be used for communication because it is in the Faulted stat
客户端口是动态调用的

EndpointAddress address = new EndpointAddress(pUrl);
            Binding bindinginstance = null;
            BasicHttpBinding ws = new BasicHttpBinding();
            ws.MaxReceivedMessageSize = 20971520;
            //ws.MaxBufferPoolSize = 99999999999;
            //ws.MaxBufferSize = 999999999;
            ws.Security.Mode = BasicHttpSecurityMode.None;
            bindinginstance = ws;
            using (ChannelFactory<T> channel = new ChannelFactory<T>(bindinginstance, address))
            {
                T instance = channel.CreateChannel();
                using (instance as IDisposable)
                {
                    try
                    {
                        Type type = typeof(T);
                        MethodInfo mi = type.GetMethod(pMethodName);//反射
                        return mi.Invoke(instance, pParams);
                    }
                    catch (TimeoutException)
                    {
                        (instance as ICommunicationObject).Abort();
                        throw;
                    }
                    catch (CommunicationException)
                    {
                        (instance as ICommunicationObject).Abort();
                        throw;
                    }
                    catch (Exception )
                    {
                        (instance as ICommunicationObject).Abort();
                        throw;
                    }
                }
            }

在window server 08没有题,在window server 2003上就报这个错了,本机调试也没有问题,对wcf安全机制不熟,苦恼了好些天。请高人帮助,谢谢!
------解决思路----------------------
表示发生了未知的异常,把你抛出错误的地方不要直接throw出来,而要使用
throw new FaultException<T>() 来抛出错误,你再看错误消息是什么就行了,window server 08是忽略了这个错误,让服务继续运行,window server 2003如果这个错误未知也未处理的话,会导致服务不可用。
------解决思路----------------------
.net 3.5装了没?
  相关解决方案