protected static string GetExceptionText(TargetException ex) { if ((ex is TargetMemoryException) || (ex is LocationInvalidException)) return ex.Message; else return String.Format ("{0}: {1}", ex.GetType ().Name, ex.Message); }