Connection string in app.config in class library

I create a solution, and inside I have three projects:

  • WCF Service Library Project

  • DataAccess Project (Class Library)

  • WCF Hosting Website

The service implementation is in project # 1, but for access to the database I use a second project that implements access to data using the class library project.

This problem is accessing data. I need to configure the connection string, but this connection string must be customizable in the production environment, I had in mind during the production process, I'm going to deploy a site, which is a very simple project that contains only a link to the WCF Service Library project, then the guy from the base department data will configure the connection string.

In development, I have app.config in the data access project, but when I make the release, app.config is built into the dll.

Any ideas how we can achieve our goal

+7
source share
3 answers

The connection string in your app.config file (data layer) is not embedded in the dll.

If you look in the app.config file in your data layer project, you will likely have a connectionStrings section. you need to put connectionStrings in web.config of your WCF service website.

This can be configured in a production environment.

+2
source share

The connection string must be in the application configuration file of the executing assembly. This means that you can provide a configuration file for your assembly along with the assembly itself, but anyone who wants to use your assembly must update their configuration file to include the values ​​that your assembly is based on.

+4
source share

I had a mistake, I used a different name in the web.config of the WCF website, just copy the exact part of app.config to web.config and now it works.

thanks for the help

+1
source share

All Articles