WCF异常-通信对象 System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为其处于“出错”状态。

chuanchang1314 2010-06-03 05:48:36
配置文件:用netNamedPipeBinding绑定

<system.serviceModel>
<services>
<service name="Service">
<endpoint address="net.pipe://localhost/Service" binding ="netNamedPipeBinding" bindingConfiguration="NamedPipesDuplexBinding" contract ="ITimeServer"/>
</service>
</services>
</system.serviceModel>

DataMeber

[DataContract]
public class UserInfo
{
private DateTime lastSessionTime;

public UserInfo()
{
lastSessionTime = DateTime.Now;
}

/// <summary>
/// 登录用户名(如:10000@1card1)
/// </summary>
[DataMember]
public string UserName
{
get;
set;
}

/// <summary>
/// 登录时间
/// </summary>
[DataMember]
public DateTime LoginTime
{
get;
set;
}

/// <summary>
/// 最后会话时间
/// </summary>
[DataMember]
public DateTime LastSessionTime
{
get
{
return lastSessionTime;
}
set
{
lastSessionTime = value;
}
}

/// <summary>
/// 登录IP
/// </summary>
[DataMember]
public string LoginIP
{
get;
set;
}

/// <summary>
/// 用户会话编号
/// </summary>
[DataMember]
public string SessionId
{
get;
set;
}

/// <summary>
/// 登录方式
/// </summary>
[DataMember]
public LoginTypes LoginType
{
get;
set;
}
}
[ServiceContract]
public interface ITimeServer
{
[OperationContract(IsOneWay = false)]
UserInfo[] GetAllUsers();
}

当调用GetAllUsers()时报错:通信对象 System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为其处于“出错”状态。
求解决方法……
...全文
3326 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuxiuming 2010-09-07
  • 打赏
  • 举报
回复
??????????????????????????????
Sunpire 2010-06-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chuanchang1314 的回复:]
调用其他返回值是装简单类型的方法不会报错,GetAllUsers()返回的是一个UserInfo数组会报错,当返回UserInfo数组的个数少的时候也不会报错,个数达到30个左右的时候就会报错。
[/Quote]
看这个描述像是WCF要发送的数据超出了WCF所允许发送的最大数据,配置一下应能解决,但是没用过netNamedPipeBinding,给出CustomBinding中的最大配置值以供参考:

<binding name="Biz.Services.FileUpload.customBinding0">
<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"
maxSessionSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
keepAliveEnabled="true" maxBufferSize="2147483647" />
</binding>

关键配置在 readerQuotas 中的 maxArrayLength、maxReceivedMessageSize 等。

netNamedPipeBinding 的配置LZ可以通过 VS2008 工具中的“WCF服务配置编辑器”来生成
chuanchang1314 2010-06-03
  • 打赏
  • 举报
回复
调用其他返回值是装简单类型的方法不会报错,GetAllUsers()返回的是一个UserInfo数组会报错,当返回UserInfo数组的个数少的时候也不会报错,个数达到30个左右的时候就会报错。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧