R
Roshawn
Hello,
I'm having a strange problem as of late. I can't seem to retrieve an object from the
cache. Here a sample of the code I'm using:
'global variable
Dim fItems as Item() 'Item is a custom class
Protected Sub Page_Load
If Not Cache("FormItems") Is Nothing Then
fItems = CType(Cache("FormItems"), Item()) 'error occurs here
Else
'... implementation omitted, but it works
End If
'... rest omitted; only works if there data in the fItems object
End Sub
When I run the above code the first time, all works as expected. I can even access the
cache. However, if I were to make a slight change to any code on the page and rebuild it
(just the page and not the whole site), I can no longer retrieve data from the cache. I
get this error:
System.InvalidCastException: Unable to cast object of type 'Item[]' to type 'Item[]'.
What the heck's going on? I've tried changing the code to use List(Of Item) and
IEnumerable(Of Item), yet the same error shows (the exception message is slightly
different as it mentions List or IEnumerable). Is there something I'm not doing? I'm
using VWD Express 2008.
Thanks,
Roshawn
I'm having a strange problem as of late. I can't seem to retrieve an object from the
cache. Here a sample of the code I'm using:
'global variable
Dim fItems as Item() 'Item is a custom class
Protected Sub Page_Load
If Not Cache("FormItems") Is Nothing Then
fItems = CType(Cache("FormItems"), Item()) 'error occurs here
Else
'... implementation omitted, but it works
End If
'... rest omitted; only works if there data in the fItems object
End Sub
When I run the above code the first time, all works as expected. I can even access the
cache. However, if I were to make a slight change to any code on the page and rebuild it
(just the page and not the whole site), I can no longer retrieve data from the cache. I
get this error:
System.InvalidCastException: Unable to cast object of type 'Item[]' to type 'Item[]'.
What the heck's going on? I've tried changing the code to use List(Of Item) and
IEnumerable(Of Item), yet the same error shows (the exception message is slightly
different as it mentions List or IEnumerable). Is there something I'm not doing? I'm
using VWD Express 2008.
Thanks,
Roshawn