【发布时间】:2015-12-27 03:26:25
【问题描述】:
我在 wcf 类库中有一个类 (myservice),它从类库中的 app.config 文件访问端点和 appsettings。这个类(myservice)是从我的控制器(web 项目)中调用的。我发现它正在尝试读取 web 项目的 web.config 文件,而不是 app.config 文件。如何访问正确的文件?
除了没有得到任何值,我得到了这个错误
不在独立exe中运行时必须指定exePath
我在我的服务中使用它-
var appSettings = ConfigurationManager.AppSettings;
var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
var serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
var clientSection = serviceModelSectionGroup.Client;
var endpoint = clientSection.Endpoints;
return new EndpointAddress(endpoint[0].Address);
【问题讨论】:
-
请在层之间包含组件的分解,并显示您的问题所在。
标签: c# wcf app-config class-library