new ChannelFactory<IAdoHelper>(“”);这种方式在单元测试下通过,但是在压力测试下报“找不到配置节”错误。
采用new ChannelFactory<IAdoHelper>(bind, address);这种方法不会报错。
ClientSection client = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;
foreach (ChannelEndpointElement el in client.Endpoints) {
if (string.Equals(el.Name, "adoService")) {
EndpointAddress address = new EndpointAddress(el.Address);
NetTcpBinding bind = new NetTcpBinding();
BindingsSection binds = ConfigurationManager.GetSection("system.serviceModel/bindings") as BindingsSection;
foreach (NetTcpBindingElement emelent in binds.NetTcpBinding.ConfiguredBindings) {
if (string.Equals(emelent.Name, el.BindingConfiguration)) {
emelent.ApplyConfiguration(bind);
}
}
_channelFactory = new ChannelFactory<IAdoHelper>(bind, address);
_channelFactory.Open();
}
}
这种做法还不行。
哪位兄弟遇见过这种情况指点一下。