c# – Accessing Properties.Settings.Default from Class? – Education Career Blog

When I create a Console App I can right click on the project in Visual Studio 2008 Pro. click Properties > Go To Settings enter a Application Scope Setting and then access it from code like


When I do the same thing in a Class Project and try to assign the the Applicatin Scope Setting to a variable like

this.mySettingVariable = Properties.Settings.Default.MySetting.ToString();

I get an the error when building that “The name ‘Properties’ does not exist in the current context.”

What am I doing wrong and how can I access the Application Scoped properties for a class project?


You forgot to add settings to the class library project. You cannot access the settings of the EXE project directly.

Giving a class library project its own settings is possible but it is a hassle. A DLL cannot have its own .config file, there’s only one: the app.exe.config file. You have to merge the entries in the DLL’s app.config file into the app.exe.config file by hand. Copy and paste with a text editor. This is not very maintainable.

Another approach is to make these settings properties of the class. And let the code in the main project initialize them from its own settings. Or just ditch settings because their a pita and use an .xml file.


Make sure you have included the namespace in the ‘usings’.

Also make sure the settings class is public.


Pulled from here

Because there is no configuration file
model for class libraries, application
settings do not apply for Class
Library projects. The exception is a
Visual Studio Tools for Office DLL
project, which can have a
configuration file.


Is your .settings file under the Properties folder in your project?

Leave a Comment