Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection string in app.config in a class library

Tags:

wcf

c#-3.0

I am creating solution and inside I have three projects:

  1. A WCF Service Library Project

  2. A DataAccess Project (Class Library)

  3. A Web site for hosting WCF service

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

That problem is in order to get data access I need to configure a connection string, but that connection string must be configurable in a production environment, I meant in production I am going to deploy the site, which is a very simple project that contains only a reference WCF Service Library Project then a guy from database department will configure the connection string.

In development I have an app.config on the data access project but when I do the release that app.config is embedded on the dll.

Any ideas how can we achieve our purpose

like image 326
Copeleto Avatar asked Mar 30 '10 21:03

Copeleto


1 Answers

The connection string must be in the application configuration file of the executing assembly. This means that you can provided the 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 relies on.

like image 82
Andrew Hare Avatar answered Sep 22 '22 13:09

Andrew Hare