-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Catch ArgumentException as well as BadImageFormatException when failing because of libraries without resources #6546
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned that this isn't the full root cause. What is different in dev17? Have you falsified the caching hypothesis I proposed offline?
src/Tasks/GenerateResource.cs
Outdated
catch (Exception e) | ||
catch (ArgumentException) | ||
{ | ||
// BadImageFormatExceptions can be wrapped in ArgumentExceptions, so catch those, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something where we can test an InnerException
to validate that this is really the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We looked at this and found https://referencesource.microsoft.com/#mscorlib/system/reflection/module.cs,857
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorporated, thanks!
The repro seems complicated by That the error message explicitly says it's a BadImageFormatException (even though it's an ArgumentException) and that we were previously catching BadImageFormatExceptions makes me fairly confident it's just a slight change in what error is being thrown. Furthermore, I tried cleaning and building several times with the blanket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go ahead with this since we (sorta) said we'd get it in for preview2.
(I still want to know what's up with the intermittent failure/toggle behavior, but this change looks good independent of that.)
This was a heinous bug to repro.
Using VS 17.0.0+, create a blank UWP app with target platform version 16299 or 17134. Build Debug/x86.
If that doesn't work, clean and build again.
If that doesn't work, clean and build again.
It should work every time, but from my testing, every other clean-build cycle succeeds even following identical steps. Every other build clean-build cycle fails with a message saying an attempt was made to load a file with incorrect format. This is normally a BadImageFormatException and caught (see comment above), but it seems that with dev 17, that is sometimes (always?) wrapped in an ArgumentException and not caught. This fixes that problem by catching both.
Maybe we should verify that the ArgumentException mentions BadImageFormatException before just continuing?
Testing: Several attempted repros in a row succeeded. It had been pretty reliably failing every other time, so that was a shift.