Search code examples
c#.netvb.netuser-config

Looking for information regarding user.config files and what causes these to be created by a .NET Framework application


I am terribly sorry if this isn't the right place to ask but what I am hoping is that someone can explain what is going on in plain English.

We're CompanyA and we were recently bought over by CompanyB. Our application was called after our Company, so for simplicity's sake let's say that we wrote an App and it was built as CompanyA.exe

Our App creates a folder %localappdata%\CompanyA where we put "our stuff"

Our app is a WPF Application written for .NET Framework 4.8 using primarily VB.NET. Our application is signed with a .SNK file

When we were bought over we changed the Company Name in the Assembly Information to "CompanyA, a CompanyB solution", but we still build the application as CompanyA.exe

Now here's the weird thing

We started noticing that a folder was created at %localappdata%\CompanyA,_a_CompanyB_solution

within that folder would be subfolders named after some of our executables, followed by Strongname followed by a bunch of random looking characters, followed by a version foldername

in each of those subfolders would be a user.config file

So, for example, we might find %localappdata%\CompanyA,a_CompanyB_solution\CompanyA.exe_StrongNamegibberishhere\1.2.3.4\user.config after we build version 1.2.3.4 of application CompanyA.exe

the user.config file would contain very little, and removing any of these files, even the entire %localappdata%\CompanyA,_a_CompanyB_solution folder, makes no difference to how usable the application is. It works fine with or without that folder.

My questions:

  1. What causes this to be created? We are not aware of having deliberately changed anything in our application to tell it to create these.
  2. What purpose do these files serve?
  3. If they are as unimportant as they seem to be (at least to our application), is there anything we can change in our application's configuration to stop it doing this?

Solution

  • In the projects properties you should have a "Settings" tab, also accessible from "properties\settings.settings" in the solution explorer.

    These settings can be used to store various configurations. Settings have two different scopes:

    1. Application: These are stored in "yourprojectName.exe.config" in your program directory, and cannot be changed from within the application itself.
    2. User: These are stored in the %LocalAppdata% folder, and is likely the cause of what you are seeing. I'm not sure exactly how it selects the subfolder name, see Where are the Properties.Settings.Default stored? for more info. These setting can be changed from within the application.

    Try searching for Settings.Default.Save(), or just Default.Save(), since these are the calls to save the default setting file. You could also try searching for ConfigurationManager. That should hopefully give you some hint about where and how these files are used.