当前位置:   article > 正文

wcf获取配置节问题

configurationmanager.getsection 配置系统未能初始化

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();

                            }

                        }

 

这种做法还不行。

哪位兄弟遇见过这种情况指点一下。


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/987811
推荐阅读
相关标签
  

闽ICP备14008679号