Click here to Skip to main content
15,895,535 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I have 2 projects in my VS 2010 solution (both using C#), and would like to have Application Setting in one project and access it from the other project. I have been doing some reading on this, and these Properties seem to be specific to a specific project. However, is there any way of either accessing the property value of one of these projects from a different project? (example below). Second best to set it in one project and have that value copied across automatically to the same property name on the other project?

I looked at a few different options, and came across property manager, but that appears to be used for C++ only, and as above I am using C#.

In Properties (Settings.Settings) from the main project (Project1):
Name: Type: Scope: Value:
Test1 String Application PC1


I can access these values easily from any classes in Project1 by using Properties.Settings.Default.Test1 (or Project1.Properties.Settings.Default.Test1). However, when I try to access this value from classes in the other project (Project2), it won't let me, and says that I need to have this specifically set in the Properties for this second project. So, I just want some way of accessing this Test1 value from Project2 (something like Project1.Properties.Settings.Default.Test1 from a class in Project2, either using get and set in Program.cs of Project1, or some other way. Any suggestions on how to do this appreciated, and some code examples would be great.

Thanks.
Posted

1 solution

 
Share this answer
 
Comments
sclarke18 28-Feb-11 8:56am    
Hi John, Thanks for your suggestion and the information. After reading down through the page, it looks like it may help. However, even though it looks good I have trying to keep all the properties within the solution file (rather than using an external file as you suggest).
sclarke18 1-Mar-11 13:23pm    
Just to mention that overall I have a main application (project), and a service project which is part of the main application. When my application is installed (from the msi) I have a form which gets the value for a setting from the user and then writing that value to the appropriate setting of the main application (project). However, I can't also write to the service project as this part is installed later in the installation process. Overall what I would really like to do is to copy the value of a certain setting (contained within app.config), to the setting (app.config) in the service project.

Stephen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900