Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch ArgumentException as well as BadImageFormatException when failing because of libraries without resources #6546

Merged
merged 3 commits into from
Jun 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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