public enum SyncExceptionTypes { FileNotExists = 0, FileAccessError = 1, AuditError = 2, }
[Serializable] public class SyncException : Exception, ISerializable { #region 属性 SyncExceptionTypes _exceptionType; public SyncExceptionTypes ExceptionType { get { return _exceptionType; } } #endregion
protected SyncException(SerializationInfo info, StreamingContext context) : base(info, context) { this._exceptionType = (SyncExceptionTypes)info.GetValue("ExceptionType", typeof(SyncExceptionTypes)); } public SyncException(string msg, SyncExceptionTypes type) : base(msg) { _exceptionType = type; }
#region ISerializable 成员
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { //调用父类的序列化以保存数据 base.GetObjectData(info, context); info.AddValue("ExceptionType", _exceptionType, typeof(SyncExceptionTypes)); }
#endregion } -------------- 最后注意在服务端配置文件里做关闭客户端错误 <system.runtime.remoting> ....................... <customErrors mode ="Off" /> system.runtime.remoting>