简体   繁体   中英

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. In that solution there are several other projects relating to the separate layers (domain project, service project, data project, and quickbooks project). ie:

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

The quickbooks project has an app.config file which it uses for certain parameters. When running locally, this all works and the quickbooks project can access the app.config file to get the settings it needs at runtime.

But when I compile the entire solution to deploy, it seems the program cannot access this app.config file.

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. But the app.config file is not.

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?

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? in 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. When IIS (or whatever) is running your project, it is running in the context of the project that you deployed. 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

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

You need to have those in your web.config as well. This way, your referenced assemblies will have access to the things it needs in the context of the running application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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