diff --git a/src/Ben.Demystifier/Ben.Demystifier.csproj b/src/Ben.Demystifier/Ben.Demystifier.csproj index 0ce62aa..78047e0 100644 --- a/src/Ben.Demystifier/Ben.Demystifier.csproj +++ b/src/Ben.Demystifier/Ben.Demystifier.csproj @@ -11,7 +11,7 @@ git true true - 0.0.5 + 0.0.6 diff --git a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs index d37ae1c..7ba844f 100644 --- a/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs +++ b/src/Ben.Demystifier/EnhancedStackTrace.Frames.cs @@ -335,27 +335,34 @@ namespace System.Diagnostics } } - var rawIL = methodBody?.GetILAsByteArray(); - if (rawIL == null) continue; - - var reader = new ILReader(rawIL); - while (reader.Read(candidateMethod)) + try { - if (reader.Operand is MethodBase mb) + var rawIL = methodBody?.GetILAsByteArray(); + if (rawIL == null) continue; + var reader = new ILReader(rawIL); + while (reader.Read(candidateMethod)) { - if (method == mb || (matchHint != null && method.Name.Contains(matchHint))) + if (reader.Operand is MethodBase mb) { - if (kind == GeneratedNameKind.LambdaMethod) + if (method == mb || (matchHint != null && method.Name.Contains(matchHint))) { - GetOrdinal(method, ref ordinal); - } + if (kind == GeneratedNameKind.LambdaMethod) + { + GetOrdinal(method, ref ordinal); + } - method = candidateMethod; - type = method.DeclaringType; - return true; + method = candidateMethod; + type = method.DeclaringType; + return true; + } } } } + catch + { + // https://github.com/benaadams/Ben.Demystifier/issues/32 + // Skip methods where il can't be interpreted + } } return false;