IIS WCF服务不使用的app.config [英] IIS WCF Service not using app.config

查看:469
本文介绍了IIS WCF服务不使用的app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS中承载一个.NET 3.5 WCF服务。该项目的服务库中有一些配置设置(数据库连接字符串,等等)的app.config文件。我通过部署一个网站项目在Visual Studio中,生成一个web.config管理端点的项目。有没有一种方法,我可以把我从服务库在app.config设置到web.config?在IIS托管服务好像是用从设计师的设置默认值,而忽视甚至在a​​pp.config中复制的expliclty。我猜这事做的事实,一个DLL不能utliize一个app.config。

I have a .NET 3.5 WCF service hosted in IIS. The project service library has an app.config file with some configuration settings (Database connection strings, etc.). I deploy the project via a website project in Visual Studio, which generates a web.config to manage the endpoints. Is there a way I can put the app.config settings from my service library in to the web.config? The IIS hosted service seems to be using default values from the settings designer, and ignoring even an expliclty copied in app.config. I'm guessing this has something to do with the fact that a DLL can not utliize an app.config.

我的服务应用程序设置为从 [MyAssembly程序] .Properties.Settings.Default 命名空间拉的设置。

My service application is set up to pull the settings settings from the [MyAssembly].Properties.Settings.Default namespace.

推荐答案

可以使用外部配置文件?

Can you use external configuration files?

您的web.config:

Your web.config:

<config>
  ...
  <connectionStrings configSource="myConnections.config"></connectionStrings>
</config>

然后你的外部myConnections.config文件:

And then your external myConnections.config file:

<connectionStrings>
  <add ... />
</connectionStrings>

您可以从您的主web.config文件中引用多个外部配置文件。看的见这篇博客对于如何/为什么这样做一个很好的解释。

You can have multiple external configuration files referenced from your main web.config file. See see this blog post for a nice explanation of how/why to do this.

我希望这有助于!

这篇关于IIS WCF服务不使用的app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆