Multiple config files in different ASPNET MVC projects

Asked

Viewed 779 times

2

I’m in trouble and maybe someone can help me.

I’m working on a project ASPNET MVC so that I structured the solution in several projects to decompose the different components.

In my main project web.config file (for example PROJETO1.Principal) I’m trying to set up to fetch the references from connection strings of the general project (for example PROJETO.Geral), in this general project in I have the app.config that contains my connections strings.

The code of General.config looks something like this:

<connectionStrings configSource="app.config"></connectionStrings>

In my code app.config is like this:

<?xml version='1.0' encoding='utf-8'?>
<connectionStrings>`
(lista minhas connections strings)`  
</connectionStrings>

However it does not work, occuring the error below:

Could not open configSource file 'app.config'.

I tried to specify the file path, the error occurs below: The attribute configSource must be a relative physical path.

It is worth noting that the error occurs at the point I try to open the list of connections using ConfigurationManager (I also tried with the WebConfigurationManager but without success).

Something else, if the file app.config was within the same project it would work without problem.

1 answer

1


I found the answer (I will post here in case anyone else has this problem).

I recreated the file in the main project, using "add existing item" and created as link.

I used that reference: http://raghurana.com/blog/? p=202

Thank you

  • Ideally, you can summarize the reference text directly in Stackoverflow so that a person who reads it can solve a similar problem, thus avoiding access to another link, as the link may no longer exist.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.