调试:如何调试“类型未标记为可序列化”当类型标记为可序列化时出现异常
我正在尝试:
((Request.Params["crmid"] != null))
在网页中。但它不断抛出序列化异常:
在中键入“QC.Security.SL.SiteUser” 装配'QC.Security, 版本=1.0.0.1,文化=中立, PublicKeyToken=null' 未标记为 可序列化。
然而,该类型(自定义 IIdentity)被标记为可序列化,如下所示:
[Serializable()]
public class SiteUser : IIdentity
{
private long _userId;
public long UserId { get { return _userId; } set { _userId = value; } }
private string _name;
public string Name { get { return _name; } }
private bool _isAuthenticated;
public bool IsAuthenticated { get { return _isAuthenticated; } }
private string _authenticationType;
public string AuthenticationType { get { return _authenticationType; } }
我不知道如何调试它,因为我无法进入序列化程序代码以找出其失败的原因。在到达[外部代码]之前,调用堆栈只有一帧深。考虑到该类型被明确标记为可序列化,该错误消息几乎毫无用处。试错调整还产生了“类型未解决成员异常”。
一切正常。但现在“突然”没有了,这通常意味着 Visual Studio 中存在一些愚蠢的错误,但重新启动“这一次”并没有帮助。所以现在我不知道这是一个愚蠢的 VS bug 还是一个完全不相关的错误,导致我出现序列化异常或者我做错了什么。
事实是,我只是不再信任 VS,因为过去几个月里我进行了多次徒劳的追逐,这些问题都通过重新启动 VS 2008 或其他一些可笑的解决方法“修复”了。
I'm trying to:
((Request.Params["crmid"] != null))
in a web page. But it keeps throwing a serialization exception:
Type 'QC.Security.SL.SiteUser' in
assembly 'QC.Security,
Version=1.0.0.1, Culture=neutral,
PublicKeyToken=null' is not marked as
serializable.
The type, a custom IIdentity, is however marked as serializable as follows:
[Serializable()]
public class SiteUser : IIdentity
{
private long _userId;
public long UserId { get { return _userId; } set { _userId = value; } }
private string _name;
public string Name { get { return _name; } }
private bool _isAuthenticated;
public bool IsAuthenticated { get { return _isAuthenticated; } }
private string _authenticationType;
public string AuthenticationType { get { return _authenticationType; } }
I've no idea how to debug this as I cant step into the serializer code to find out why its falling over. The call stack is only one frame deep before it hits [External Code]. And the error message is next to useless given that the type is clearly marked as serializable. Trial and error adjustments also produced a Type is not resolved for member exception.
It was working fine. But now "all of a sudden" it doesn't which typically means some dumb bug in Visual Studio but rebooting doesn't help "this" time. So now I dont know if it's a stupid VS bug or a completely unrelated error for which Im getting a serialization exception or something I'm doing wrong.
The truth is I just dont trust VS anymore given the number of wild goose chases Ive been on over the last several months which were "fixed" by rebooting VS 2008 or some other rediculous workaround.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我已经解决了这个问题。这是另一个 VS / 卡西尼号问题。根据 此 url 和 此 url 解决方法是让 SiteUser继承自 MarshalByRefObject。
这是必要的,因为:
“开发者开发者开发者咳嗽”
O.k so I've fixed the problem. It was/is yet another VS / Cassini issue. As per this url and this url the workaround is to make SiteUser inherit from MarshalByRefObject.
This is neccessary because:
"Developers developers developers cough"