Override assembly names loaded through AssemblyResolve handlers when searching currently loaded assemblies. #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The program that led me down this rabbit hole is STORY OF SEASONS: A Wonderful Life's launcher. (steam appid 2111170).
It uses an AssemblyResolve handler to load assemblies from its own resources, but it ships a version of System.Threading.Tasks.Extensions that doesn't match the version requested by its assemblies.
Framework handles this by assuming whatever's returned from AssemblyResolve handlers is the requested assembly and caching that for future loads.
Mono doesn't do this and double loads this assembly (due to two of the launcher's dependencies triggering a load), which leads to a failure to setup a vtable due to mismatching types (they're the same type, but loaded from two different instances of the same assembly).
I have a more realistic repro of the issue here. It should build fine by just using
msbuild
Not entirely happy with this solution, but the bits of the assembly loader that insert the assembly into
MonoDomain::domain_assemblies
do not receive the name it was requested under, and passing that in would entail changing parts of Mono's assembly load hooks, which I wasn't comfortable with. Let me know if that would be preferrable and I can try to go for it.