I am attempting to use a new settings file in my Windows Forms Application with C#.
After I deleted the old Settings File (Settings1.settings) and created the new one(Settings.settings).
As I began editing the code that uses the settings file I realized that the new settings file is not being recognized. Example:

There is a custom Settings Class being used from a namespace created by our company that is causing some of the conflict. How do I point the code at the right settings file?
In trying to duplicate what you have done I noticed the Namespace of the Settings.Designer.cs file went from this( I am using a console app to test).
namespace ConsoleApplication1.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool Test {
get {
return ((bool)(this["Test"]));
}
set {
this["Test"] = value;
}
}
}
}
to
namespace ConsoleApplication1 {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool Temp {
get {
return ((bool)(this["Temp"]));
}
set {
this["Temp"] = value;
}
}
}
}
If you will notice the Namespace went from ConsoleApplication1.Properties to ConsoleApplication1 so if you add .Properties to the Namespace of the new Settings file it should take care of your problem.
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