调试:如何调试“类型未标记为可序列化”当类型IS被标记为可序列化时例外 [英] Debugging: How to debug "Type is not marked as serializable" exception when the type IS marked as serializable

查看:514
本文介绍了调试:如何调试“类型未标记为可序列化”当类型IS被标记为可序列化时例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图:

((Request.Params["crmid"] != null))

在网页中。但是它不断地引发序列化异常:

in a web page. But it keeps throwing a serialization exception:



assembly'QC.Security中键入'QC.Security.SL.SiteUser' ,
Version = 1.0.0.1,Culture = neutral,
PublicKeyToken = null'未标记为
可序列化。

Type 'QC.Security.SL.SiteUser' in assembly 'QC.Security, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

然而,该类型的定制IIdentity标记为可序列化,如下所示:

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.

这是正常工作。但是现在突然之间它不是通常意味着Visual Studio中的一些笨蛋,但是重新启动并不能帮助这个时间。所以现在我不知道这是一个愚蠢的VS错误或一个完全不相关的错误,我得到一个序列化异常或我做错了。

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.

事实是,我只是不信任VS,因为在过去几个月里,通过重新启动VS 2008或一些固定的野鹅追逐数量其他可怕的解决方法。

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.

推荐答案

好,我已经解决了问题。这是/是另一个VS / Cassini问题。根据这个 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.

这是必要的,因为:


问题是,cassini将会将
分解为单独的AppDomains,
在IIS中不会发生(甚至
,尽管他们说它可以)。
因为
这样,当Atlas试图将
转换为JSON到
服务器上的东西时,它会执行某些操作并切换
,并且.User自定义主体不会
反序列化,因为汇编是
不在GAC,没有注册
其他AppDomain。

The issue is that cassini will break into separate AppDomains at will, which doesn't happen in IIS (even though they say it CAN). Because of this, when Atlas is trying to convert to the JSON to something on the server, it does something and switches and the .User custom principal doesn't deserialize because the assembly is not in the GAC and not registered with the other AppDomain.

开发人员开发人员咳嗽

这篇关于调试:如何调试“类型未标记为可序列化”当类型IS被标记为可序列化时例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆