简体   繁体   English

如何在Web项目解决方案visual studio中的单独项目中部署app.config

[英]How to deploy app.config in separate project within a web project solution visual studio

I have an ASP.NET MVC 4 web project (as opposed to website) solution. 我有一个ASP.NET MVC 4 Web项目(而不是网站)解决方案。 In that solution there are several other projects relating to the separate layers (domain project, service project, data project, and quickbooks project). 在该解决方案中,还有一些与单独的层(域项目,服务项目,数据项目和quickbooks项目)相关的其他项目。 ie: 即:

Web
  - Domain
  - Data
  - ApplicationServices
  - Quickbooks
    - app.config
  - web.config

The quickbooks project has an app.config file which it uses for certain parameters. quickbooks项目有一个app.config文件,用于某些参数。 When running locally, this all works and the quickbooks project can access the app.config file to get the settings it needs at runtime. 在本地运行时,这一切都有效,并且quickbooks项目可以访问app.config文件以获取运行时所需的设置。

But when I compile the entire solution to deploy, it seems the program cannot access this app.config file. 但是当我编译整个解决方案进行部署时,程序似乎无法访问此app.config文件。

If I look in the resulting Release Package that gets built from the Release Build process, there is one bin folder, and I see the quickbooks.dll in it. 如果我查看从Release Build过程构建的最终Release包,则有一个bin文件夹,我在其中看到quickbooks.dll。 But the app.config file is not. 但app.config文件不是。

I am definitely weak in the whole build process area in visual studio, so forgive me if this is elementary. 我在视觉工作室的整个构建过程中非常弱,所以请原谅我,如果这是基本的。

1.) Is this even possible, or do all app.config files need to be in the top level Web project? 1.)这是否可行,或者所有app.config文件是否都需要在顶级Web项目中?

2.) If it is possible, and I hope it is as I am trying to encapsulate the quickbooks project as much as possible, where should that app.config file end up after the build? 2.)如果可能的话,我希望尽可能多地封装quickbooks项目,app.config文件应该在构建之后到哪里? in bin? 在bin? in the web root? 在网络根目录?

If that project is referenced by another project (in your case the web project), it's app.config will not be included in the release package. 如果该项目被另一个项目引用(在您的情况下是Web项目),那么它的app.config将不会包含在发布包中。 When IIS (or whatever) is running your project, it is running in the context of the project that you deployed. 当IIS(或其他)正在运行您的项目时,它将在您部署的项目的上下文中运行。 Any references will be loaded into the context of the running project. 任何引用都将加载到正在运行的项目的上下文中。

All that to say, if you have settings in your app.config, such as 所有这一切,如果您在app.config中有设置,例如

<appSettings>
 <add key="name" value="value"/>
</appSettings>

You need to have those in your web.config as well. 您还需要在web.config中包含这些内容。 This way, your referenced assemblies will have access to the things it needs in the context of the running application. 这样,引用的程序集就可以在正在运行的应用程序的上下文中访问所需的内容。

暂无
暂无

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

相关问题 如何将app.config添加到Visual Studio 2012 Web Express lib项目? - How to add app.config to Visual Studio 2012 Web Express lib project? Visual Studio:项目中的“ App.config”的自定义名称,而不是项目外部的自定义名称? - Visual Studio: Custom name for “App.config” in project, not outside project? 如何在同一解决方案中从另一个项目获取App.Config - How do I get the App.Config from a different project within the same solution 如何在不同的解决方案之间共享相同的 Visual Studio 项目? 不同的 app.config 和 settings.settings - How to share same Visual Studio project between different solutions? Different app.config and setttings.settings Visual Studio 2012测试项目正在从machine.config而非从app.config加载配置设置 - visual studio 2012 test project is loading configuration settings from machine.config but not from app.config 如何在 Visual Studio Web 2013 中添加 app.config 或 web.config 文件? - How can I add an app.config or web.config file in Visual Studio Web 2013? 如何在不同项目的单个解决方案中访问App.config? - How can i access App.config in single solution of different project? Visual Studio 2013-如何在解决方案中调试项目 - Visual Studio 2013 - How to debug a project within a solution 从 Visual Studio 解决方案中提取项目作为单独的项目 - Extracting a project as a separate project from the Visual Studio solution Visual Studio / MSBuild将引用类库的app.config复制为* .dll.config到当前项目的bin文件夹 - Visual Studio/MSBuild copy referenced class library's app.config as *.dll.config to bin folder of current project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM