Application Settings - Custom Defined Type

Hi, any help here would be greatly appreciated.

I'm having trouble with the Applications Settings in VB.NET 2005.

Here is what I am doing:

I have an application that needs to store (ability to add, edit, remove) a list of applications on a PC. So I created a Class called ApplicationSettings and a Class called ApplicationSettingsCollection.

ApplicationSettings is serialized and contains basic information like AppName, Path, Version.

ApplicationSettingsCollection is defined as:

<Serializable()> _
Public Class ApplicationSettingsCollection
Inherits System.Collections.Generic.List(Of ApplicationSettings)
End Class

My hopes were to save each application in an Application Settings.
So I went to the properties of my project and added an Application Setting with the name: AppSettings and the Type ApplicationSettingsCollection

When i did this, my project created a reference to itself under references, so later in the project i had ambiguous reference erros and it wouldn't compile.

Once I removed that reference to itself, It works fine but when i do something like the following:

dim alcAppSettingsCollection as ApplicationSettingsCollection
(remember ApplicationSettingsCollection is a collection of ApplicationSettings)

alcAppSettingsCollection = my.settings.appsettings (don't know if I need to do this or not)

...

dim appNewApp as ApplicationSettings
...(set all variables here)...
alcAppSettingsCollection.Add(appNewApp)

When i run my program I get NullReferenceException was unhandeled. This also happens if I try

My.Settings.AppSettings.add(appNewApp)

I'm not too sure what to do from here, or if I am even defining my AppSettings correctly by using a custom type.

Any insight on the ambiguous refernece it created or how to get this to work would be greatly appreciated.

Thanks,

Bobby



Answer this question

Application Settings - Custom Defined Type

  • Application Settings - Custom Defined Type