Mono.Cecil's AssemblyResolver should search target assembly's directory#10
Merged
Merged
Conversation
a971306 to
f040463
Compare
einaregilsson
pushed a commit
that referenced
this pull request
Mar 4, 2016
Mono.Cecil's AssemblyResolver should search target assembly's directory
Contributor
|
Thanks a lot. Will try to get the package published today. :) |
Contributor
|
Package published! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If an assembly that is to be modified by InjectModuleInitializer contains attributes with constructor parameters or properties of a type defined in a third-party library, Mono.Cecil will often fail to load that third-party assembly. This is the case because, by default, Mono.Cecil only searches for assembly files in "." and "bin", relative to
Directory.GetCurrentDirectory()(see exhibit A and exhibit B). Unless the current directory is the same directory as the assembly to be modified (which is not the case in the InjectModuleInitializer nuget package), this causes a failure with a "Failed to resolve Assembly" message.For example, if the to-be-modified assembly has a dependency on Newtonsoft.Json, and it has classes defined like the following, InjectModuleInitializer will fail:
This pull request adds the directory of the to-be-modified assembly to Mono.Cecil's search path so that the assembly where those attribute parameters exist can be successfully loaded.
Fixes #8. (I work at the same company as @killyosaur and obtained his code in order to figure out exactly what was happening. It turns out the problem had nothing to do with Visual Studio 2015.)