public static Exception GetInnerMostException(this Exception ex) { //Extract true exception from static intializers (e.g. LicenseException) while (ex.InnerException != null) { ex = ex.InnerException; } return ex; } }