Skip to content

Commit

Permalink
Catch ArgumentException as well as BadImageFormatException when faili…
Browse files Browse the repository at this point in the history
…ng because of libraries without resources (#6546)
  • Loading branch information
Forgind committed Jun 29, 2021
1 parent e9593e8 commit 1b7661f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Tasks/GenerateResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3151,10 +3151,13 @@ internal void ReadAssemblyResources(String name, String outFileOrDir)
// We can't easily filter those. We can simply skip them.
return;
}
catch (Exception e)
catch (ArgumentException e) when (e.InnerException is BadImageFormatException)
{
// BadImageFormatExceptions can be wrapped in ArgumentExceptions, so catch those, too. See https://referencesource.microsoft.com/#mscorlib/system/reflection/module.cs,857
return;
}
catch (Exception e) when (!ExceptionHandling.IsCriticalException(e))
{
if (ExceptionHandling.IsCriticalException(e))
throw;
_logger.LogErrorWithCodeFromResources("GenerateResource.CannotLoadAssemblyLoadFromFailed", name, e);
}

Expand Down

0 comments on commit 1b7661f

Please sign in to comment.