Asp.net mvc 4 加载ASP.Net配置文件时出错
我有一个使用AspNetSqlProfileProvider的现有MVC 4应用程序,配置如下:Asp.net mvc 4 加载ASP.Net配置文件时出错,asp.net-mvc-4,asp.net-profiles,Asp.net Mvc 4,Asp.net Profiles,我有一个使用AspNetSqlProfileProvider的现有MVC 4应用程序,配置如下: <properties> <add name="MyTypeAs" type="System.Collections.Generic.List`1[[My.Namespace.MyTypeA, My.Namespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]" serializeA
<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>
现在,我希望更新系统(不删除旧配置文件),如下所示:
<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");
List myTypeAs=
(列表)HttpContext.Current.Profile.GetPropertyValue(“MyTypeA”);
将引发异常:
试图加载此属性的类型导致以下错误:无法加载类型“System.Collections.Generic.HashSet`1[System.Int32]”
请注意,我正在引用类型为List
的属性,但异常表示它无法加载该类型
System.Collections.Generic.HashSet`1[System.Int32]
我在web.config中指定类型的方式出错了吗?还有别的原因吗
所有这些都发生在Visual Studio 2010 SP1中,选择了.NET 4运行时。结果表明,与
列表不同,哈希集
需要完全限定的程序集名称
System.Collections.Generic.HashSet`1[[System.Int32]],System.Core,版本=4.0.0.0,区域性=neutral,PublicKeyToken=b77a5c561934e089