Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi,

I'm writing a two project application. Lets call the first project, ProjectA and the second project ProjectB.

ProjectA contains all the application settings and is a WinForms application. ProjectB is a Service that needs to read ProjectA's settings. So here's the steps I've followed.

1. Make ProjectA's Settings Property Access Modifier Public instead of Internal
2. Add a reference to ProjectA in ProjectB
3. Add a Using to define ProjectA's Namespace in ProjectB
4. Code like this:
bLvl6Rpt = ProjectA.Properties.Settings.Default.Lvl6Report;

What I get in bLvl6Rpt is Lvl6Report's default value, not what is actually set. How do I read the actual settings from ProjectA? I know I can do this easy with an XML file, however I'm trying to learn how this works.

Thank you,
Glenn
Posted

The concept is wrong.
If this is an application for a single user, it looks like shared settings. Consequently, store the settings file in a common location (e.g. %PROGRAMDATA%\YourCompany\YourProductSuite\SharedSettings.xml). The classes used for managing the settings go into one dll which is used by both your desktop application and the service.
If the service deals with several client applications and is expected to apply client-specific settings, such settings are actually parameters to methods of the service and ought to be passed to the service as method parameters from the client.
 
Share this answer
 
Comments
gmhanna 10-Apr-14 8:12am    
Hi - So what you're saying is if I put my ShareSettings.xml into the Program Data directory, like you have said (I have other things stored there already), then the service will find the settings set by the desktop application?

Do I have to do anything special such as setting a path to the program data directory so it knows where to find the ShareSettings.xml file?

Thank you,
Glenn
I think you can achieve this easily using web-services.
Refer this link.It may help you.
Web Services in C# and .Net[^]
 
Share this answer
 

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