I am stuck trying to get the download list from ViewState using ASP.NET 4 and VB.NET. When I try to retrieve a collection using:
Public Property ItemsForImport As List(Of ImportItem)
Get
Return IIf(ViewState("ItemsForImport") Is Nothing, New List(Of ImportItem), CType(ViewState("ItemsForImport"), List(Of ImportItem)))
End Get
Set(value As List(Of ImportItem))
ViewState("ItemsForImport") = value
End Set
End Property
I get an exception:
[A]System.Collections.Generic.List`1[ImportItem] cannot be cast to [B]System.Collections.Generic.List`1[ImportItem].
Type A originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Type B originates from 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
Debugging shows that the collection is not null and contains 2 elements. The class is defined only once, and I cleared my temporary files fromC:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Usually I sometimes see this (I suppose everyone does) with quick changes during debugging, but it goes after a few updates. Is something missing?
source
share