我有一個現成的MVC 4應用程序使用AspNetSqlProfileProvider,配置是這樣的:錯誤加載ASP.Net檔案
<properties>
<add name="MyTypeAs"
type="System.Collections.Generic.List`1[[My.Namespace.MyTypeA, My.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" serializeAs="Binary" />
</properties>
現在我想更新系統(而不刪除舊的配置文件)是這樣的:
<properties>
<add name="MyTypeAs"
type="System.Collections.Generic.List`1[[My.Namespace.MyTypeA, My.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" serializeAs="Binary" />
<add name="MyHashOfInts"
type="System.Collections.Generic.HashSet`1[System.Int32]" serializeAs="Binary" />
</properties>
我沒有問題在以前的項目中添加額外的屬性。如果序列化數據來自其中未定義附加屬性的先前版本,則加載該屬性 產生默認(T)。然而,隨着這種變化,當我的控制器執行這一行:
List<MyTypeA> myTypeAs =
(List<MyTypeA>)HttpContext.Current.Profile.GetPropertyValue("MyTypeA");
一個異常被拋出:
Attempting to load this property's type resulted in the following error: Could not load type 'System.Collections.Generic.HashSet`1[System.Int32]'.
注意到,我引用List<MyTypeA>
類型的屬性,但異常說,它無法加載類型
System.Collections.Generic.HashSet`1[System.Int32].
我在如何在web.config中指定類型時犯了錯誤嗎?還有其他原因嗎?
所有這些都發生在選擇了.NET 4運行時的Visual Studio 2010 SP1中。