CKY CKY - 4 months ago 27
C# Question

What is the best way to handle Multi-instance Properties.Settings.Default.Save()

I have a C# Winforms application that uses app.config to save 3 simple settings.

  • Last selected path as

  • Window state as

  • Updated as

This is a multi-instance application and when a user has more then one instance open and closes the application group, they are met with

System.Configuration.ConfigurationErrorsException: Failed to save settings: The configuration file has been changed by another program.

What is the best way to manage this?

I know I can catch the error and return out of application-exit method but this seems improper. It would seem to me that there should be a way to check if another instance is working in the file before calling
and then return out of the method.


Catch the exception and call Properties.Settings.Default.Reload() then attempt to save again.