.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Treeview of Multi assembly App Settings
 

Treeview of Multi assembly App Settings

My app (vs2008 Soln) uses a few assemblies (projects).
I would like to have a central treeview on a form that can enable the setting/viewingof my.settings from the different assemblies.
How would I go about collecting the settings and then posting the changes back.
I have pretty good treview understanding.
loftusbergus
Yes, your class library projects turn into assemblies (dlls) that you can use in your main project. However, only your main .exe project can have a settings file. You'll need to merge the app.config files of your class library projects with your main project's app.config. It's fugly.
Hans Passant.
  • Marked As Answer byloftusbergus Friday, September 26, 2008 8:45 PM
  •  
nobugz
"from the different assemblies" is pretty mysterious. It's pretty simple if you use a PropertyGrid:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PropertyGrid1.SelectedObject = My.Settings
End Sub


Hans Passant.
nobugz
It was my understanding that when you have a multi project solution, each project becomes a dll file of its own. Is this what an assembly is?
Whether or not it is, each project has mysettings that can store the state of that projectsclass fields (settings) if necessary. So going back to my original question can i bring these together by code somehow. The property grid is a good thing provided it allows me to view the settings from the different projects altogether.
loftusbergus
Yes, your class library projects turn into assemblies (dlls) that you can use in your main project. However, only your main .exe project can have a settings file. You'll need to merge the app.config files of your class library projects with your main project's app.config. It's fugly.
Hans Passant.
  • Marked As Answer byloftusbergus Friday, September 26, 2008 8:45 PM
  •  
nobugz
reflection? Could i get each assemby and then do a
For Each spv As SettingsPropertyValue In My.Settings.PropertyValues
or
maybe I code into each assembly a settings controller class :

Public class SettingsControl

Public shared function GetSettings as System.Configuration.SettingsPropertyValueCollection
return My.Settings.PropertyValues
end function

public shared sub SetSettings(settings asSystem.Configuration.SettingsPropertyValueCollection)
'Im getting a bit frightened now
'System.Configuration.SettingsPropertyValueCollection implements IEnumerable - not IEnumerable( of T)
Dim incomingSettings As New List(Of SettingsPropertyValue)
For Each spv As SettingsPropertyValue In settings
incomingSettings.Add(spv)
Next

Dim MySettings As New List(Of SettingsPropertyValue)
For Each spv As SettingsPropertyValue In My.Settings.PropertyValues
MySettings.Add(spv)
Next

Dim commonSettings = From sNew In inComingSettings, sOld In MySettings _
Where sOld.Property.PropertyType IssNew .Property.PropertyType _
And sOld.Property.Name = sNew.Property.Name _
Select sOld, sNew

For Each pair In commonSettings
pair.sOld.PropertyValue = pair.sNew.PropertyValue
Next
My.Settings.Save()


end sub
end class


in th main I could then
reflect through each assembly and see if theres aSettingsControlClass

assemby1.GetSettings
inherit treeNode to have an AddSettings(settings asSystem.Configuration.SettingsPropertyValueCollection)
or
propertygridOnTabbedPage1.DOsomethingy =assemby1.SettingsControlClass.GetSettings ??







loftusbergus

You can use google to search for other answers

Custom Search

More Threads

• how to kill a process
• what is reflection?
• Best Options For Fixing Corrupt Performance Counter Libraries?
• How to add an additional field in the existing database table and adding an additional table in the existing database
• Updating settings Windows Service
• Sending/Receiving Excel messages using MSMQ
• Problem in convert DataSet.table
• .GetType() issues with access different variable values
• ConfigurationElementCollection inheritance bug
• General Operator System Name?