2

According to MSDN, one can add customized settings files to ones project for convenient management of groups of settings.

So I created a custom settings by visual designer, set all properties as a User Scoped to be able to save them.I bind some control properties to this customized settings. And change some values mannually through Properties.CustomSettings.MyValue = x;

But when I do Properties.CustomSettings.Default.Save() - nothing happens. The changes are not persisted between application run (I'm aware about Debug version change) .

I searched a file in the directorites that ConfigurationManager gives me (according to this post) but didn't find any track of this CustomSettings.

So, what is the trick with saving this Customized Settings Files and How to save Customized Settings Files?

Community
  • 1
  • 1
MajesticRa
  • 13,770
  • 12
  • 63
  • 77

1 Answers1

1

Ok, now I've got a right answer. Everything is OK that this custom settings were created under the dll file.

The problem is with this question Application.UserAppDataPath strange behaviour

If one have AssemblyVersion with automatic Build and Revision Numbers and have AssemblyFileVersion in AseemblyInfo.cs, say, of exe that uses this dll, then Application.UserAppDataPath will throw ArgumentException "Illegal characters in path." Application.UserAppDataPath is used to build path to this config file to save this CustomSettings.

But ApplicationSettingsBase just eats all exceptions that happens inside, so the file is just not saved and nobody could even think about AssemblyFileVersion in AseemblyInfo.cs of exe...

Ohhh my god... 8 hours of fighting with this ... feature...

Community
  • 1
  • 1
MajesticRa
  • 13,770
  • 12
  • 63
  • 77
  • Thank you for sharing this resolution. It is a very silly exception and not expected. I get the same exception but I guess I have a different scenario! – NoChance Apr 14 '20 at 11:14