简体   繁体   English

IIS WCF服务未使用app.config

[英]IIS WCF Service not using app.config

I have a .NET 3.5 WCF service hosted in IIS. 我在IIS中托管了.NET 3.5 WCF服务。 The project service library has an app.config file with some configuration settings (Database connection strings, etc.). 项目服务库具有一个app.config文件,其中包含一些配置设置(数据库连接字符串等)。 I deploy the project via a website project in Visual Studio, which generates a web.config to manage the endpoints. 我通过Visual Studio中的网站项目部署该项目,该项目会生成一个web.config来管理端点。 Is there a way I can put the app.config settings from my service library in to the web.config? 有没有办法将服务库中的app.config设置放到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. IIS托管服务似乎正在使用设置设计器中的默认值,甚至忽略了复制到app.config中的显式内容。 I'm guessing this has something to do with the fact that a DLL can not utliize an app.config. 我猜测这与DLL无法使用app.config的事实有关。

My service application is set up to pull the settings settings from the [MyAssembly].Properties.Settings.Default namespace. 我的服务应用程序设置为从[MyAssembly].Properties.Settings.Default命名空间中提取设置设置。

Can you use external configuration files? 可以使用外部配置文件吗?

Your web.config: 您的web.config:

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

And then your external myConnections.config file: 然后是您的外部myConnections.config文件:

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

You can have multiple external configuration files referenced from your main web.config file. 您可以从主web.config文件中引用多个外部配置文件。 See see this blog post for a nice explanation of how/why to do this. 有关如何/为什么执行此操作的详细说明,请参见此博客文章

I hope this helps! 我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM