System.ServiceModel.Channels.ReceivedFault在哪里,为什么不能序列化? [英] Where is System.ServiceModel.Channels.ReceivedFault and why isn't it serializable?

查看:90
本文介绍了System.ServiceModel.Channels.ReceivedFault在哪里,为什么不能序列化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工作中编写了一个异常记录系统,该系统将异常序列化到文件中,并在以后读取文件并将异常写入数据库.在我收到System.ServiceModel.Channels.ReceivedFault异常和 我的序列化因以下错误而中断:

I've written an exception logging system at my work that serializes exceptions to a file and at a later time reads the files and writes the exceptions to the DB. This was working fine until I got a System.ServiceModel.Channels.ReceivedFault exception and my serialization broke with this error:

程序集'System.ServiceModel,版本= 3.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089'中的类型'System.ServiceModel.Channels.ReceivedFault'未标记为可序列化.

Type 'System.ServiceModel.Channels.ReceivedFault' in Assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

我尝试研究此类,但未在MSDN上列出它,也无法在对象浏览器中找到它.有人可以告诉我该文档在此类上的位置,在对象浏览器中的位置以及为什么不能序列化吗? 是个例外吗?我以为是,或者可能是一个因公开而暴露的财产.

I tried looking into this class and I don't find it listed on MSDN and was unable to find it in the object browser either. Can someone please tell me where the documentation is on this class, where it is in object browser and why it's not serializable if it's an exception? Which I'd assume it is or possibly it's a property that is exposed on an excpetion.

任何信息将不胜感激.

推荐答案

此类本身并不是一个例外,它是一个 MessageFault .它是System.ServiceModel.Channels.MessageFault的内部子类,并且您发现它无法直接序列化.但是,您可以通过调用其WriteTo来对其进行序列化 方法(取决于您使用的绑定的消息版本,但是在创建日志记录系统时,您可以传递此信息).
This class isn't an exception per se, it's a MessageFault. It's an internal subclass of System.ServiceModel.Channels.MessageFault, and as you found out it can't be serialized directly. You can, however, serialize it, by calling its WriteTo method (which will be dependent of the message version of the binding you're using, but when you're creating your logging system you can pass this information along).


这篇关于System.ServiceModel.Channels.ReceivedFault在哪里,为什么不能序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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