用新信息延长例外

[Serializable] public class CommonsDbException : Exception { public CommonsDbException() { } public CommonsDbException(string message, object[] args) { base.message = string.Format(message, args); } public CommonsDbException(string message, Exception innerException) : base(message, innerException) { } protected CommonsDbException(SerializationInfo info, StreamingContext context) : base(info, context) { } } 

 public CommonsDbException(string message, object[] args) { base.message = string.Format(message, args); } 

是无效的,我不能在base.Message上设置消息。

我想创造新的信息,我能做什么。 父亲的消息没有固定者。

你需要链接构造函数:

 public CommonsDbException(string message, object[] args) : base(string.Format(message, args)) { } 

这将调用祖先中的Exception(string message)构造函数。

这里有一篇关于构造函数的文章,你应该阅读。

exception具有接受消息的重载构造函数 。

你试过了吗

 public CommonsDbException(string message, object[] args) : base(string.Format(message, args), null) { }