我有它返回的產品清單,並隨後顯示頁面的功能,但是當我嘗試加載頁面的列表中,我得到一個神祕的錯誤:無效的類型在VB.NET
[A]System.Collections.Generic.List`1[Product] cannot be cast to
[B]System.Collections.Generic.List`1[Product].
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'.
對我來說,這兩種類型看起來完全相同。拋出異常就行了:
Dim products As List(Of Product) = AppDAL.FindProducts(New ProductSearchEventArgs(SearchText, ProductSearchEventArgs.TextCriteria.Contains))
我的方法的簽名是:
Public Shared Function FindProducts(e As ProductSearchEventArgs) As List(Of Product)
無論是產品,這是調用FindProducts方法或AppDAL類的頁面有命名空間,我可以」不知道爲什麼這不起作用
您是否嘗試過重建項目並重新啓動Visual Studio? – 2011-05-07 15:16:47