错误加载ASP.Net简介 [英] Error Loading ASP.Net Profile
问题描述
我有一个现成的MVC 4应用程序使用AspNetSqlProfileProvider,配置是这样的:
I have an existing MVC 4 application that uses the AspNetSqlProfileProvider, configured like this:
<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>
现在我想升级系统(不删除旧的配置文件)是这样的:
Now I wish to update the system (without removing the old profiles) like this:
<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>
我有没有问题,在增加previous项目的附加属性。如果序列化的数据是从$ P $,其中没有定义的附加属性pvious版本,加载该属性
产生默认值(T)。然而,随着这种变化,当我的控制器执行这一行:
I have had no problem adding additional properties in previous projects. If the serialized data was from a previous version where the additional property was not defined, loading that property yielded default(T). However, with this change, when my controller executes this line:
List<MyTypeA> myTypeAs =
(List<MyTypeA>)HttpContext.Current.Profile.GetPropertyValue("MyTypeA");
抛出异常:
试图加载此属性的类型导致以下错误:未能加载类型'System.Collections.Generic.HashSet`1 [System.Int32]
Attempting to load this property's type resulted in the following error: Could not load type 'System.Collections.Generic.HashSet`1[System.Int32]'.
请注意,我引用类型的属性列表与LT; MyTypeA&GT;
但异常说,它无法加载类型
Notice that I'm referencing a property of type List<MyTypeA>
but the Exception says it cannot load the type
System.Collections.Generic.HashSet`1 [System.Int32]
System.Collections.Generic.HashSet`1[System.Int32].
我做出的我是如何规定的web.config中的类型错了吗?是否有其他原因?
Did I make a mistake in how I specified the type in web.config? Is there another cause?
所有这一切都在Visual Studio 2010 SP1与发生选定.NET 4运行。
All of this is happening in Visual Studio 2010 SP1 with the .NET 4 runtime selected.
推荐答案
原来,从不同列表&LT; T&GT;
,的HashSet&LT; T&GT;
需要一个完全合格的程序集名称
It turns out that, different from List<T>
, HashSet<T>
requires a fully qualified assembly name.
System.Collections.Generic.HashSet`1 [System.Int32],System.Core程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089
System.Collections.Generic.HashSet`1[[System.Int32]], System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
这篇关于错误加载ASP.Net简介的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!