-
Notifications
You must be signed in to change notification settings - Fork 428
Avoid a first-chance exception in ConflictResolver.ResolveConflict #326
Comments
/cc @dsplaisted this code lives in the SDK as well. On desktop though we just call GetAssemblyName. I suppose we could use the core implementation everywhere and it would avoid the exception. |
Yes, that method doesn't throw on native binaries. Please use it :) |
Ported to the SDK: dotnet/sdk#1215 |
Curious what file you're hitting this on. We'd only be going down this path if you had a native file conflict in your package closure, which shouldn't be the case for most projects if they are up-to-date. |
Unfortunately I have no recollection of what I was doing and under what circumstances I've hit this. Sorry :) |
We've decided that the tradeoffs for avoiding this first chance exception aren't worth it. I've opened https:/dotnet/corefx/issues/19928 to track adding an API that can be used to do this better in the future. |
I hit a first-chance BadImageFormatException a lot with this stack:
This is because here we try to get the assembly version of any .dll even if it's not a managed assembly:
https:/dotnet/standard/blob/master/Microsoft.Packaging.Tools/tasks/ConflictItem.cs#L56
I recommend using this simple code to first check whether a binary even represents a managed assembly:
https:/KirillOsenkov/MetadataTools/blob/master/PEFile/IsManagedAssembly.cs
Only attempt to retrieve the assembly name after we've checked that the binary is indeed an assembly.
The text was updated successfully, but these errors were encountered: