So no one has any advice or suggestions for me? MVP's? If someone has a
small sample project that works, could you post it so I can see if my dev
machine is somehow screwed up?
This is a great .NET feature, and I'd like to get it working so I can use
it.
Keith
> Hello,
>
[quoted text clipped - 36 lines]
>
> Keith
eh, according to vb.net 2005 express help, ConfigurationManager.AppSettings
returns a collection and hence should be access the way collection are to
be accessed
the following will give you an idea in vb. as for other languages, I am sure
you can look it up under configurationmanager.appsetting
' Get appSettings.
Shared Sub GetAppSettings()
' Get the appSettings.
Dim appSettings As NameValueCollection = _
ConfigurationManager.AppSettings
' Get the collection enumerator.
Dim appSettingsEnum As IEnumerator = _
appSettings.Keys.GetEnumerator()
' Loop through the collection and
' display the appSettings key, value pairs.
Dim i As Integer = 0
While appSettingsEnum.MoveNext()
Dim key As String = appSettings.Keys(i)
Console.WriteLine("Name: {0} Value: {1}", _
key, appSettings(key))
i += 1
End While
End Sub 'GetAppSettings
Actually if you only have scalar simple application settings and no such
thing as user1, user2 or nor anything with multiple values,
My.Settings.<heightor whatever> is simpler
> Hello,
>
[quoted text clipped - 15 lines]
> ConfigurationManager.AppSettings[<settingname>]
> ConfigurationSettings.AppSettings[<settingname>]
ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Locati
on).AppSettings.Settings[<settingname>]
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSe
ttings.Settings[<settingname>]
> ExeConfigurationFileMap efm = new ExeConfigurationFileMap();
> efm.ConfigFileName = Assembly.GetEntryAssembly().Location + ".config";
[quoted text clipped - 12 lines]
>
> Keith
Keith - 03 Oct 2006 00:33 GMT
> eh, according to vb.net 2005 express help,
> ConfigurationManager.AppSettings
> returns a collection and hence should be access the way collection are to
> be accessed
Yes I'm aware of that, but since the collection returned is derived from
NameValueCollection, you can index into the collection using either an int
or a string. Why iterate through a collection and check each key/value pair
when you can just ask explicitly for the item you want? Regardless,
iterating makes no difference; the settings are still not found.
> Actually if you only have scalar simple application settings and no such
> thing as user1, user2 or nor anything with multiple values,
> My.Settings.<heightor whatever> is simpler
Simpler, yes, but only if you are in a Class or assembly that has access to
the original collection or its definition. This does not work if you are
trying to access settings from a satellite assembly that does not hold a
reference to the assembly that "owns" the settings classes. For example, it
you are using reflection to load .dlls.