zoukankan      html  css  js  c++  java
  • wcf获取配置节问题

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

                                }

                            }

    这种做法还不行。

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


  • 相关阅读:
    动态调用WebService以及传递复杂对象
    2021.1112月 SQL、前端、Java文章学习及资源记录
    字符串导出word
    Dapper 返回存储过程值
    SQL2008 查询XML
    兼容各浏览器的iframe方法
    .net 后台任意设置 控件显示和隐藏就OK
    List 增删该查
    iis 7上发布mvc报错:403.14Forbidden Web 服务器被配置为不列出此目录的内容
    kafka使用入门api2
  • 原文地址:https://www.cnblogs.com/tommyli/p/1446404.html
Copyright © 2011-2022 走看看