问题描述
我正在使用 WCF RIA 服务测试版 使用 Silverlight 3.0,我希望能够从客户端配置超时.我知道底层技术是 WCF,并且默认超时似乎是我预期的 60 秒.
I'm using the WCF RIA Services Beta with Silverlight 3.0 and I want to be able to configure the timeout from the client. I know that the underlying technology is WCF and the default timeout seems to be 60 seconds as I would expect.
是否有一种简单的方法可以控制此设置和其他 WCF 设置?
Is there an easy way to control this and other WCF settings?
我的第一个想法是尝试 DomainContext OnCreated 挂钩点,在 RIA 服务进行测试之前可用的 RIA 服务概述 pdf 文件中提到.DomainContext 对象不再提及该方法,尽管它仍然存在?我不确定这是文档滞后的情况还是表明我不应该使用此扩展点.
My first thought is to try the DomainContext OnCreated hook point which was mentioned in the RIA Services Overview pdf file that was available prior to RIA Services going beta. The MSDN documentation for the DomainContext object no longer mentions the method although it is still there? I'm not sure if this is a case of the documentation lagging behind or an indication that I shouldn't use this extensibility point.
namespace Example.UI.Web.Services
{
public sealed partial class CustomDomainContext
{
partial void OnCreated()
{
// Try and get hold of the WCF config from here
}
}
}
推荐答案
域上下文创建后的任意一行:
Either one line after domain context creation:
((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
或部分类
public partial class LibraryDomainContext
{
partial void OnCreated()
{
if(DesignerProperties.GetIsInDesignMode(App.Current.RootVisual))
((WebDomainClient<LibraryDomainContext.ILibraryDomainServiceContract>)this.DomainClient).ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
}
}
这篇关于为来自 Silverlight 3 客户端的 WCF RIA 服务调用配置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!