I store some key/value strings used by my application in a table, there are about 30-40 items.
I have a class which loads the values from the database and stores them in a string dictionary as key/value pairs.
I want to persist this collection throughout the lifetime of the application and perform a lookup on the collection whenever and wherever I need to.
So I invoke the load method of the class in the Application_Start method in global.asax.
In my load method I want to assign the dictionary to the Cache or application object.
The problem I am having is with referencing either the Cache or Application object from this class.
Here's an example of where I am, which causes a "Object reference not set to an instance of an object." error:
Public Class AppString
Public Shared myCache As New Cache
Public Shared Sub LoadStrings()
' Creates and initializes a new StringDictionary.
Dim myStrings As New StringDictionary()
myStrings.Add("STRING1", "Value 1")
myStrings.Add("STRING2", "Value 2")
myStrings.Add("STRING3", "Value 3")
myCache("LanguageStrings") = myLanguageStrings
Which one would be best, Cache or Application, for this amount of items and how do I get a reference to it so I can assign my dictionary to it?