Jack,
In addition to the other comments, I normally use Activator.CreateInstance
along with Type.GetType.
For example: You can store the full type name of your form in the
app.config, then you can use Activator.CreateInstance to create an instance
of that form.
Something like:
<configuration>
<appSettings>
<add key="mainForm" value="namespace.form, assembly" />
</appSettings>
</configuration>
Imports System.Configuration
Public Sub Main()
Dim mainFormTypeName As String =
ConfigurationSettings.AppSettings("mainForm")
Dim mainFormType As Type = Type.GetType(mainFormTypeName)
Dim mainFormObject As Object =
Activator.CreateInstance(mainFormType)
Dim mainForm As Form = DirectCast(mainFormObject, Form)
Application.Run(mainForm)
End Sub
To store the "navigation" I would consider using a custom configuration
section, instead of appSettings.
Create a custom configuration section via configSections and implementing
the System.Configuration.IConfigurationSectionHandler. I would pattern the
custom section handler after DictionarySectionHandler (support: add, remove,
clear) or use a class derived from DictionarySectionHandler...
<navigation>
<add form="Form 1" type="namespace.form1, assembly" />
<add form="Form 2" type="namespace.form2, assembly" />
</navigation>
Then within your code you can use ConfigurationSettings.GetConfig to return
the above section of the app.config. Depending on what you do in your
IConfigurationSectionHandler.Create method (I would create a HashTable) will
decide what GetConfig returns.
See the following on how to create new sections via the configSections
section.
http://msdn.microsoft.com/library/d...de/html/cpconconfigurationsectionhandlers.asp
and:
http://msdn.microsoft.com/library/d...ref/html/gngrfconfigurationsectionsschema.asp
Also read about the System.Configuration.ConfigurationSettings class and
other classes in the System.Configuration namespace.
Hope this helps
Jay