的ChannelFactory没有在端点上

的ChannelFactory没有在端点上

本文介绍了的ChannelFactory没有在端点上,为什么一个地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建的ChannelFactory的新实例:

When I create a new instance of a ChannelFactory:

var factory = new ChannelFactory<IMyService>();

和我创建一个新的通道,我有一个例外说,端点的地址为空。

and that I create a new channel, I have an exception saying that the address of the Endpoint is null.

我的我的web.config里面的配置如前所述,一切都因为它应该是(端点尤其是地址)。

My configuration inside my web.config is as mentioned and everything is as it is supposed to be (especially the address of the endpoint).

如果我创建一个新MyServiceClientBase,它加载所有的配置从我的通道工厂:

If I create a new MyServiceClientBase, it loads all the configuration from my channel factory:

var factoryWithClientBase = new MyServiceClientBase().ChannelFactory;
Console.WriteLine(factoryWithClientBase.Endpoint.Address); //output the configuration inside the web.config


var factoryWithChannelFactory = new ChannelFactory<IMyService>();
Console.WriteLine(factoryWithChannelFactory.Endpoint.Address); //output nothing (null)

为什么?

推荐答案

我终于找到了答案。的ChannelFactory不会从你的web.config / app.config中读取信息。 ClientBase(当时用的ChannelFactory工作)一样。

I finally found the answer. ChannelFactory doesn't read information from your Web.Config/app.config. ClientBase (which then work with a ChannelFactory) does.

这一切成本核算我几个小时的工作,但我终于找到了正当的理由。

All this costed me a few hours of work but I finally found a valid reason.

:)

这篇关于的ChannelFactory没有在端点上,为什么一个地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:10