The Debug and Release folders on your machine contain the built executable (.exe), as well as a configuration file (.exe.config), which includes the settings. Maybe this file was missing on target machine? Check if such file was published. You can also try copying it manually to check if it works.
SettingsPropertyNotFoundException when saving a property after publishing application
I am working on a WPF app.I have created the Properties.Settings.Default file in Visual Studio and I'm trying to use it for storing user settings. I made a string property called PortName with scope User, like this: .
When I'm trying to write a new value to that property, or read the current value after publishing my app, I get a SettingsPropertyNotFoundException - "The settings property PortName was not found", just like it doesn't exist. Screenshot:
public static string PortName {get; set;}
public static void LoadUserSettings()
{
try
{
PortName = Properties.Settings.Default["PortName"].ToString();
}
catch (Exception ex)
{
MessageBox.Show($"{ex.Message}");
}
}
When I test this locally, it works just fine - the setting is saved correctly, both in DEBUG and RELEASE mode.
When I publish the app and do the same with it, the error occurs.
How to make sure that the setting PortName exists on the client's end?
Developer technologies | Windows Presentation Foundation
Developer technologies | C#
2 answers
Sort by: Most helpful
-
-
DaisyTian-1203 11,646 Reputation points
2021-03-04T08:08:39.14+00:00 Please add default settings by steps: Right click the project> Choose the Properties> Go to Settings Tab > Click
This project does not contain a default settings file, Click here to create on
. The your project directory is as follows:
Then you can addPortName
in it and used it as in the .net framework projects before
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.