Visual C# Developer Center >
Visual C# Forums
>
Visual C# General
>
Application settings (user.config) - explicitly loading
Application settings (user.config) - explicitly loading
- Is it possible to decide when the application settings are loaded (talking about the standard behavior with default settings). AFAIK it is loaded automatically when my (windows form) application starts. I - however - would first like to display an information screen and then start the loading, so that there is no delay.
Answers
- The config subsystem is delay loaded. It only loads the information when it is first needed. There shouldn't be any delays. The app.config is loaded pretty early on because it contains startup information but user.config won't be loaded until you do something to reference a user setting. But config files aren't generally that large so as far as a delay is concerned you probably wouldn't even notice it unless you had a bunch of custom sections and slow handlers but that isn't a problem for user.config.
Are you having a specific problem that has caused you to believe that the user.config loading is slowing down your app? Generally speaking the slowdown occurs because an app tries to load too many assemblies on startup.
Michael Taylor - 11/6/09
http://p3net.mvps.org- Marked As Answer byHarry ZhuMSFT, ModeratorFriday, November 13, 2009 1:57 AM
All Replies
- The config subsystem is delay loaded. It only loads the information when it is first needed. There shouldn't be any delays. The app.config is loaded pretty early on because it contains startup information but user.config won't be loaded until you do something to reference a user setting. But config files aren't generally that large so as far as a delay is concerned you probably wouldn't even notice it unless you had a bunch of custom sections and slow handlers but that isn't a problem for user.config.
Are you having a specific problem that has caused you to believe that the user.config loading is slowing down your app? Generally speaking the slowdown occurs because an app tries to load too many assemblies on startup.
Michael Taylor - 11/6/09
http://p3net.mvps.org- Marked As Answer byHarry ZhuMSFT, ModeratorFriday, November 13, 2009 1:57 AM
- Ok, it helps me to understand that loading takes place when first using a setting. You have analyzed the issue very well, I have not paid any attention to this until recently. Usually there are very few data in such a setting I did not even think about it.In my last application I am "abusing" the settings as a persistent cache. I am reading data from several third party systems, and store them as serialized objects. Firstly my approach was serializing the objects "manually" to the local disk, but more as a test I just have added a list of my persistent objects in the settings and this does work very well without writing a single line of code. I understand that this not the native concept of settings, but actually I did not find any reason not to do it, except academic ones.But indeed the loading of around "10 MB serialized data" takes 3-4 seconds in my scenario, which is acceptable for me. Only I wanted control when I spend the few seconds, which in my case is after the GUI displays. With your answer in mind this should be no problem at all, when I only access the settings at an appropriate point of time.


