Duplicate references when using the Importer
See original GitHub issueGood morning, I already commented a question #338 about how to add external methods to the assembly in .NET Core.
I have also read: #104
I have adapted the AssemblyResolver so that it works correctly with .NET Core with the advice you gave me.
If I want to get for example, System.Convert
resolving works correctly to get it from System.Runtime.Extensions
, and everything works perfectly.
But for example, imagine that System.Runtime.Extensions
is already in the module as a reference (because the original application already has it) there is the problem, instead of reusing it, add it again, and then the module has 2 identical references.
This does not cause any problems, the application starts and works correctly even if there are two references the same, but of course, it is rare.
So, I have done one thing, before looking for what library I need for “x” type, I check the current referenced libraries, and I try to solve the “x” type with each of them.
TryToResolve
all it does is create the TypeRef that is needed and use the .Resolve()
. In case it is resolved, it would be:
So suppose I want to use System.Convert
I call this method and get all the original references of the assembly, for example:
// System.Drawing.Primitives, Version = 4.2.1.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a
// System.Runtime, Version = 4.2.2.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a
// System.Runtime.Extensions, Version = 4.2.2.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a
try to solve System.Convert
in each of them, and get it in System.Runtime.Extensions
, so it returns the resolved type.
If I add the method solved directly, I get the error that it is in another module.
So, I import it this way, everything works perfectly, but the reference System.Runtime.Extensions
is now twice.
I could understand that this twice if it were different, for example, that I import it manually, but the reference is being obtained from the AssemblyRef of the module, it cannot be that it is another version basically because it obtains the one it already has, that is, it is identical
So why double if it is the same?
I am doing something wrong ? Should I “import” in another way, or is the error “resolving”?
Thank you very much, and sorry to waste your time,
A cordial greeting,
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top GitHub Comments
I suggest you have a look at the actual fields of the assembly refs. Most likely you’ll see that the hash and/or flags fields have different values.
Thank you, they are different. That’s why I solved it as I told you before.
Thank you very much for your help, I will close the problem, I hope that my contributions and yours can help someone who is in this situation, greetings.