C# Exception的子类Serializable警告
编译时发出的警告:
警告 CA2237[1] 将 [Serializable] 添加到 'HardwareException',原因是此类型实现了 ISerializable。
Cause[1]
An externally visible type implements the System.Runtime.Serialization.ISerializable interface and the type is not marked with the System.SerializableAttribute attribute. The rule ignores derived types whose base type is not serializable.
Rule Description
To be recognized by the common language runtime as serializable, types must be marked with the SerializableAttribute attribute even if the type uses a custom serialization routine through implementation of the ISerializable interface.
To fix a violation of this rule, apply the SerializableAttribute attribute to the type.
应对:
如果不跨越AppDomain传递/抛出异常,什么也不不用做。——这是静态分析器(FxCop tool[2])的过爱之心。[3]
reference:
[1] Mark ISerializable types, https://msdn.microsoft.com/library/ms182350.aspx
[2] FxCop, https://msdn.microsoft.com/en-us/library/bb429476(v=vs.80).aspx
[3] Stack Overflow, http://stackoverflow.com/questions/11327404/deriving-from-exception-classes-warning-ca2237-mark-iserializable-types-with-s
C# Exception的子类Serializable警告的更多相关文章
- Java基础 try...catch...catch 使用Exception,去捕获其子类异常
JDK :OpenJDK-11 OS :CentOS 7.6.1810 IDE :Eclipse 2019‑03 typesetting :Markdown code ...
- 序列化---Serializable与Externalizable源码
Serializable接口总结: 1. java.io.Serializable接口是一个标识接口,它没有任何字段和方法,用来表示此类可序列化: 2. 父类声明该接口,则其与其所有子类均可序列化,都 ...
- Java Error和Exception区别
Error和Exception都继承自Throwable: 二者不同之处: Exception: 1.可以是可被控制(checked)或者不可控制(unchecked): 2.表示一个由程序员导致的错 ...
- Java异常处理总结Exception\Error
Java异常处理总结Exception\Error 2012-12-28 08:17:17| 分类: JAVA | 标签:java |举报|字号 订阅 Java异常处理总结 ...
- 面试官:小伙子,你给我说一下Java Exception 和 Error 的区别吧?
前言 昨天在整理粉丝给我私信的时候,发现了一个挺有意思的事情.是这样的,有一个粉丝朋友私信问我Java 的 Exception 和 Error 有什么区别呢?说他在面试的时候被问到这个问题卡壳了,最后 ...
- Android开发学习之路-关于Exception
Exception在Java中是表示异常的一个类.它是Throwable的子类. 而Exception的子类RuntimeException是一个特殊的异常类,在代码中不需要对此类进行throw,而是 ...
- 2015年11月26日 Java基础系列(五)异常Exception
序,异常都是标准类Throwable的一些子类的对象. Throwable类的几个方法 1 getMessage() 返回描述该异常的信息 2 printStackTrace() 把消息和栈的跟踪记录 ...
- Exception&Error
Java异常处理 1:什么是异常 异常(Exception)也叫异常.在Java编程语言中,异常就是程序在运行过程中由于硬件设备问题.软件设计错误.缺陷等导致的程序错误. 1.1:想打开的文件不存在 ...
- java 异常处理 Throwable Error 和Exception
Java异常类层次结构图: 异常的英文单词是exception,字面翻译就是“意外.例外”的意思,也就是非正常情况.事实上,异常本质上是程序上的错误,包括程序逻辑错误和系统错误. 比如使用 ...
随机推荐
- 异常:exception和error的区别
Throwable 是所有 Java 程序中错误处理的父类 ,有两种子类: Error 和 Exception . Error :表示由 JVM 所侦测到的无法预期的错误,由于这是属于 JVM ...
- The J1850 Core
http://www.digidescorp.com/wp-content/uploads/2012/02/J1850-Datasheet-pdf.pdf
- 直接运行PowerShell脚本
以管理员权限运行下面语句:ftype Microsoft.PowerShellScript.1="C:\WINDOWS\system32\windowspowershell\v1.0\pow ...
- .net+mssql制作抽奖程序思路及源码
近期一直在研究数据库,刚好有个项目要做抽奖程序,恩,拿来练练手吧. 抽奖程序: 思路整理,无非就是点一个按钮,然后一个图片旋转一会就出来个结果就行了,可这个程序的要求不是这样的,是需要从数据库中随机抽 ...
- C#中Thread类中Join方法的理解(转载)
指在一线程里面调用另一线程join方法时,表示将本线程阻塞直至另一线程终止时再执行 比如 using System; namespace TestThreadJoin { class Pro ...
- UVA 573 (13.08.06)
The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...
- Android学习之路
Android基础 整理下个人认为新手们必须要掌握的知识点,顺便也会附带相应觉得不错的讲解博客地址. 两分钟彻底让你明白Android Activity生命周期(图文)! Activity实际开发中使 ...
- 即时通信(RPC)的Rtmp实现--代码实现篇
实现的一般步骤是: step 1: 定义NetConnection对象连接rtmp,并监听NetStatusEvent.NET_STATUS事件 step 2: 在NetStatusEvent.NET ...
- [AngularJS] Accessing Data in HTML -- controllerAs, using promises
<!DOCTYPE html> <html> <head> <title>Access Data From HTML</title> < ...
- UVA 1069 - Always an integer(数论)
1069 - Always an integer 题意:给定一个多项式,推断是否总是整数 思路:LRJ大白上的例题,上面给出了证明,仅仅要1到k + 1(k为最高次数)带入方程都是整数,那么整个方程就 ...