I have multiple projects in a .NET C# 2008 Win Forms Solution. Some of these projects have settings that are defined in them (through the project properties, settings UI portion – not a config file). I am attempting to build a debug portion of my application (hidden away from the users) that would then display what these settings are currently set at. I have the below code that gets all of the assemblies:
AssemblyName[] assemComponents = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
foreach (AssemblyName assemName in assemComponents)
{
ListViewItem item = listComponents.Items.Add(assemName.Name);
item.SubItems.Add(assemName.Version.ToString());
}
Currently this block of code just puts the list of assembly names and their version in a control. However, I would like to know if using these Assembly objects (or any others for that matter) I can retrieve the project settings that have been set.
Thank you all for your help and please let me know if I can provide additional detail.
When you add items to the Settings Designer, Visual Studio generates a class for reading/writing those settings to a file; it also includes a static Default property for accessing an instance of this class that holds the default values. (See Settings.Designer.cs in your project).
You can locate these classes and inspect them with reflection: