silverlight过一段时间后访问wcf服务失败

bigzoom 2010-11-16 05:15:24
silverlight界面打开的时候创建了一个wcf的链接,接着一个小时不去操作界面,再次操作界面上的按钮(使用之前创建的wcf服务链接再次去访问服务)访问服务时提示wcf通讯异常:NotFound!请遇到过该问题的解答一下。
...全文
124 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
bigzoom 2010-11-17
  • 打赏
  • 举报
回复
我是做了这方面考虑的,下面是我的代码,不过即使设置了各个Timeout属性不同的时间值,还是会存在这种问题。


public static T Create()
{
BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
basicHttpBinding.MaxReceivedMessageSize = Int32.MaxValue;
basicHttpBinding.MaxBufferSize = Int32.MaxValue;
basicHttpBinding.ReceiveTimeout = TimeSpan.FromMinutes(2);
basicHttpBinding.OpenTimeout = TimeSpan.FromMinutes(2);
basicHttpBinding.SendTimeout = TimeSpan.FromMinutes(2);
basicHttpBinding.CloseTimeout = TimeSpan.FromMinutes(1);
return (T)Activator.CreateInstance(_ServiceType, basicHttpBinding, EndPointAddress);
}
海涵德 2010-11-17
  • 打赏
  • 举报
回复
这些仅是调用wcf时的时间设置,本想看看能不能给你点提示,你的问题也是我经常遇到的,应该是属于wcf的保护吧。
海涵德 2010-11-16
  • 打赏
  • 举报
回复
这是正常的。这是我程序中使用初始使用wcf的一段代码,如果你能看懂下面代码,不妨研究一下
public class Class1
{
// 使用例子:
// Private _wcf As New ServiceReferenceWCF.ServiceWCFClient
// use_optical_line_wcf(_wcf, "../Services/ServiceOpticalLine.svc") '


public static EndpointAddress getEndpointAddress(string relative_uri)
{
return new EndpointAddress(new Uri(Application.Current.Host.Source, relative_uri));
}

public static void use_wcf(ServiceReferenceWCF.ServiceWCFClient wcf_client_instance, string end_point_address)
{
EndpointAddress _end_point_address = default(EndpointAddress);

_end_point_address = ClassesOptialLineShared.getEndpointAddress(end_point_address);
// _end_point_address = ClassesOptialLineShared.getEndpointAddress("../Services/ServiceOpticalLine.svc")

#if TRACE
// 调用wcf超时的解决办法
wcf_client_instance.Endpoint.Binding.OpenTimeout = new TimeSpan(0, 1, 0);
wcf_client_instance.Endpoint.Binding.CloseTimeout = new TimeSpan(0, 1, 0);
wcf_client_instance.Endpoint.Binding.SendTimeout = new TimeSpan(0, 18, 0);
wcf_client_instance.Endpoint.Binding.ReceiveTimeout = new TimeSpan(0, 18, 0);
#elif
wcf_client_instance.Endpoint.Binding.OpenTimeout = new TimeSpan(0, 1, 0);
wcf_client_instance.Endpoint.Binding.CloseTimeout = new TimeSpan(0, 1, 0);
wcf_client_instance.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
wcf_client_instance.Endpoint.Binding.ReceiveTimeout = new TimeSpan(0, 5, 0);
#endif

wcf_client_instance.Endpoint.Address = _end_point_address;
}
}

不过这是vs2008+sp1+sl3的代码。

8,734

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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