Types should not derive from System.ApplicationException

Rule ND2210 .NET Framework Usage / System

Deriving exceptions from ApplicationException was recommended in .NET Framework 1; the recommendation is now to derive from System.Exception or one of its System namespace subclasses. Matches exception classes deriving from ApplicationException.

How to fix

Derive matched exception types from System.Exception or one of its System namespace subclasses.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Types should not derive from System.ApplicationException</Name>
// <Id>ND2210:TypesShouldNotExtendSystemApplicationException</Id>

warnif count > 0 from t in Application.Types where
  t.DeriveFrom("System.ApplicationException".AllowNoMatch())
select new {
   t,
   Debt = 5.ToMinutes().ToDebt(),
   Severity = Severity.Medium
}

//<Expl>
// The *{0}* should not derive from *System.ApplicationException*
// but from *System.Exception* instead.
//</Expl>

//<Desc>
// Deriving exceptions from *ApplicationException* was recommended in .NET
// Framework 1; the recommendation is now to derive from **System.Exception**
// or one of its *System* namespace subclasses. Matches exception classes
// deriving from *ApplicationException*.
//</Desc>

//<HowToFix>
// Derive matched exception types from **System.Exception** or one of its
// *System* namespace subclasses.
//</HowToFix>

.NET Framework Usage / System: all 12 items