C#.NET编译来自不同项目的settings.settings文件中的溶液注入到1配置文件溶液、配置文件、不同、文件

由网友(抹不去回忆的伤)分享简介:我有一个解决方案,其中一个项目是业务层和另一个项目是web前端,它具有BL项目作为参考。他们每个人都有自己的settings.settings文件,但在构建时BL配置文件不会被复制到bin目录。我们之前已经得到了解决这个问题的办法就是所有设置在BL的app.config复制到Web的web.config文件。但是,这似...

我有一个解决方案,其中一个项目是业务层和另一个项目是web前端,它具有BL项目作为参考。他们每个人都有自己的settings.settings文件,但在构建时BL配置文件不会被复制到bin目录。我们之前已经得到了解决这个问题的办法就是所有设置在BL的app.config复制到Web的web.config文件。但是,这似乎是一个完美的解决方案。

I have a Solution where one project is the business layer and the other project is the web front-end, which has the BL project as a reference. They each have their own settings.settings file, but at build time the BL config file is not copied into the bin directory. The way we have gotten around this before is just to copy all the settings in the BL app.config into the Web's web.config file. But this seems like an imperfect solution.

额外的信息: 该网站的项目并不需要访问BL的配置文件,但BL的DLL需要能。

Extra Info: The web project does not need to access the BL's config file, but the BL's dll needs to be able to.

问题: 有没有办法让输出到bin目录中引用的项目配置文件,除了在构建时将文件拷贝?有没有一种方法,以这两个配置文件的自动编译成一个文件?如何做其他人管理,在同一个解决方案多个配置文件?

Questions: Is there a way to have the referenced projects config file outputted to the bin directory ,besides adding a file copy in the build event? Is there a way to compile both of the config files into one file automatically? How do other people manage multiple config files in the same solution?

推荐答案

我认为,业务层的项目不应该有自己的配置文件。在业务层,应该使用配置管理器来获取这些设置。 现在,如果你是指在Web应用程序的业务层,它会从web.config中挑选值,如果你是指它在Windows / WPF应用程序,它会从app.config中获得的值。

I think the Business Layer project shouldn't have its own config files. In the Business Layer, one should use Configuration Manager to get the settings. Now if you refer the Business Layer in WebApp, it would pick the values from web.config and if you refer it in Windows/WPF app, it would get the values from app.config.

在你的情况,我会说不要有在业务层的配置值,突出部把他们的Web应用程序。让您的业务层的类库项目。

In your case, I would say not to have the config values in Business Layer, jut put them in the WebApp. Make your Business Layer a Class Library project.

阅读全文

相关推荐

最新文章