任何人都有一个想法,我怎么可以通过代码,基于会话的WCF服务maxConcurrentSessions的当前设置?获取当前默认maxConcurrentSessions设置
即使未在服务配置文件中设置maxConcurrentSessions,我也希望获得此值,换句话说,我希望在此情况下获取默认值。
基本上我试图毫无疑问地证明maxConcurrentSessions在我当前环境中的默认值是什么。
谢谢!
任何人都有一个想法,我怎么可以通过代码,基于会话的WCF服务maxConcurrentSessions的当前设置?获取当前默认maxConcurrentSessions设置
即使未在服务配置文件中设置maxConcurrentSessions,我也希望获得此值,换句话说,我希望在此情况下获取默认值。
基本上我试图毫无疑问地证明maxConcurrentSessions在我当前环境中的默认值是什么。
谢谢!
关键是要设置在配置文件中的一些throttlingBehavior的属性,但离开maxConcurrentSessions出来:
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100"/>
然后在服务器上:
ServiceHost host = new ServiceHost(typeof(MyService));
string msg = "Service Behaviors:" + Environment.NewLine;
foreach (IServiceBehavior behavior in host.Description.Behaviors)
{
msg += behavior.ToString() + Environment.NewLine;
if (behavior is ServiceThrottlingBehavior)
{
ServiceThrottlingBehavior serviceThrottlingBehavior = (ServiceThrottlingBehavior)behavior;
msg += " maxConcurrentSessions = " + serviceThrottlingBehavior.MaxConcurrentSessions.ToString() + Environment.NewLine;
}
}
EventLog.WriteEntry("My Log Source", msg, EventLogEntryType.Information);
这给我800。它支持那里的文档,说默认值是WCF 4.0及更高版本的100 * nb处理器。
只是为了直接设置记录:从[MSDN](http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior.maxconcurrentsessions.aspx)它说,从.NET 4.5:“默认值是处理器数量的100倍。“而对于.NET 4.0 [MSDN](http://msdn.microsoft.com/zh-cn/library/system.servicemodel.description.servicethrottlingbehavior.maxconcurrentsessions(v = vs.100).aspx)指出:“缺省值是10.” :) – 2013-10-14 13:10:31