views:

747

answers:

2

Hey everyone..

I am trying to store/retrieve a value that is stored in the Application Settings. From within my console application I can not seem to access the Properties.Setting namespace. My web surfing has revealed that a little more work might be needed to do this from within a Console application. How does one do this?

string test = Properties.Settings.Default.MyString;

Thanks!

+2  A: 

By default there is no Settings file in a Console application. However, you can add one simply by right-clicking your project in the solution explorer, choosing "Properties" and then in the resulting window, click the "Settings" tab.

There should be a link saying "Click here to create a default settings file". Once that's created, you're off to the races.

womp
The settings tab doesn't a "Click here to create a default settings file" link. But I can "View Code" which takes me to a settings.cs file. There are some event handlers that need to be wired up. Does anyone know of a good example of hoe this is done?
Nick
Hmm.... that's odd. What version of Visual Studio are you on?
womp
A: 

So.. Once I created my Settings.settings file in the project that is saving the property I ran into the issue of how to access these properties from another project in the same solution. The settings object is sealed so you have to use a little trickery to gain access to the property values in another project. I found my solution here:

http://blog.decarufel.net/2007/10/getting-access-to-settings-in-another.html

Basically you create a link file to the Settings.Designer.cs file in the project where you are trying to retrieve the values.

I hope this helps someone with a similar issue.

-Nick

Nick