I have a solution in visual studio 2010 which constists of 7 different projects. I want to keep some settings that is used by logic in project X in project X's app.config file. However if I create an app.config like the one below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="PrimaryEmail" value="[email protected]"/>
<add key="CCEmail1" value="[email protected]"/>
</appSettings>
</configuration>
and then in a class in project X uses code like this:
ConfigurationManager.AppSettings["PrimaryEmail"]
it can't find it and ConfigurationManager.AppSettings.Count returns 0.
However if I create the same app.config in the StartUp project Y of the solution it finds the data in that one.
Is it possible somehow to use the information in app.config in project X in this case? I guess it has to do soemthing with the fact that I have many projects in the same solution.
config file in Project X is available in Project X only. If your startup project is Y, then you need to have config file in this project. No other way to do this
UPDATE:
As an option you can you post build event and run copy command to copy config file from one project into another.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With