Creating & accessing an application wide array.

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I am developing a web solution.

I would like to create a dynamically sized array of strings at application
start (presumably in the "Application_Start" event), which can then be
referenced through subsequent "page level" objects.

I only want to dynamically create the array once, so it seems that it cannot
be defined in either the "Global.asax" module or the "HttpSessionState"
object.

So, can this be achieved? If so how / where do I created the array?

Thanks, Steve
 
OK, so after a little research, I have found the "Application" object. In my "Application_Start" event I now have;

Dim strMyVal As String = "test-string"
Application.Add("testvar", strMyVal)

Which seems to work (well at least doesn't give me an exception). I am now trying to retrieve the variable with;

Return Application.Item("testval")

Which gives me; "Object reference not set to an instance of an object."

Any ideas? Thanks, Steve
 
OK, so after a little more trial and error, it looks as though you have to reference the application object through the a page object. In a nutshell, problem solved! Sorry to have wasted time for those who have read & actually thought about this on my behalf!

Steve

OK, so after a little research, I have found the "Application" object. In my "Application_Start" event I now have;

Dim strMyVal As String = "test-string"
Application.Add("testvar", strMyVal)

Which seems to work (well at least doesn't give me an exception). I am now trying to retrieve the variable with;

Return Application.Item("testval")

Which gives me; "Object reference not set to an instance of an object."

Any ideas? Thanks, Steve
 
Back
Top