WCF channelfactory异常

时间:2014-04-13 07:44:29

标签: c# wcf

我尝试建立一个连接到另一台电脑,但后来我尝试创建一个频道我得到一个例外,我不知道什么是这个问题,因为有些电脑可以工作

这是代码:

var ep = "net.tcp://" + targetIpAddress + ":9985/IBC";
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
binding.ListenBacklog = 2000;
binding.MaxConnections = 2000;
binding.TransferMode = TransferMode.Buffered;
binding.MaxReceivedMessageSize = 1048576;
binding.SendTimeout = new TimeSpan(0, 1, 0);

ChannelFactory<IBlissRequest> pipeFactory = new ChannelFactory<IBlissRequest>(binding, new EndpointAddress(ep)); //here i get the exception
client.ChannelFactory = pipeFactory;

例外:Source array was not long enough. Check srcIndex and length, and the array's lower bounds.

完整堆栈跟踪:

bij System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
bij System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 
bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
bij System.ServiceModel.Description.TypeLoader.GetKnownTypes(Object[] knownTypeAttributes, ICustomAttributeProvider provider) 
bij System.ServiceModel.Description.TypeLoader.UpdateOperationsWithInterfaceAttributes(ContractDescription contractDesc, ContractReflectionInfo reflectionInfo) 
bij System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation) 
bij System.ServiceModel.ChannelFactory`1.CreateDescription() 
bij System.ServiceModel.ChannelFactory.InitializeEndpoint(Binding binding, EndpointAddress address) 
bij System.ServiceModel.ChannelFactory`1..ctor(Binding binding, EndpointAddress remoteAddress) 
bij System21.Network.InterBlissCommunication.InternalMethodInvoke(String targetIpAddress, Boolean Async, Object state, CallbackMethod callbackMethod, BpuMethod MethodName, Object[] Parameters)

这个代码被多个线程所接受,当我对它进行锁定时,问题似乎已经解决了(问题可能是它尝试使用相同的ipAddress进行重复连接)

0 个答案:

没有答案