[英]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.