3

When project settings (Project>Properties>Settings tab in VS) are used to store user or application settings they are stored in assembly.dll.config or assembly.exe.config file and are also embedded into the assembly every time the assembly is built.

After the deployment, user settings are stored in user.config file (this is at least true with click-once deployment, I'm not sure how it's handled by msi deployed or with standard setup apps) and whenever user changes a setting this is where new value is stored and retreived from at run-time.

Now, all that makes sense but I just tried deleting the app.exe.config file of a deployed app and after that the app would crash on start and it would not work until the app.exe.config file was restored.

If that is the case and the app cannot use the embedded settings when the config file is missing or tempered with, what is the point of embedding the settings in the first place and are there any scenarios where these embedded settings would get to be used?

Dean Kuga
  • 11,878
  • 8
  • 54
  • 108
  • This post (and the links it provides) could help you to understand http://stackoverflow.com/questions/17272956/location-of-app-config-file-used-by-referenced-library-for-my-settings/17286006#17286006 – Chris Jul 01 '13 at 20:28
  • Setting values are not embedded in an assembly, only the typesafe property for them. Clearly we cannot see why the default value for the setting makes your code crash. – Hans Passant Jul 02 '13 at 00:10
  • Sorry Hans but you're wrong on this one, I used reflection tool to look into assemblies and the values are in there... I'll double check tomorrow... – Dean Kuga Jul 02 '13 at 01:42
  • Just to confirm that default setting values are in deed compiled into assembly, it looks like this `[DefaultSettingValue("1")]` in reflector... – Dean Kuga Jul 02 '13 at 16:31

1 Answers1

0

If you create a user control in a separate assembly, and have settings in that assembly, BUT you don't copy those settings into your main executable's settings, then your application won't find those settings in its config file at runtime. However, your user control will use the compiled-in settings that are embedded in the assembly, and it won't crash; this is one situation where having the embedded values helps.

philu
  • 795
  • 1
  • 8
  • 17