question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate references when using the Importer

See original GitHub issue

Good 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.

Screenshot_10

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.

Screenshot_11

TryToResolve all it does is create the TypeRef that is needed and use the .Resolve(). In case it is resolved, it would be:

Screenshot_12

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.

Screenshot_13

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:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
0xd4dcommented, Mar 4, 2020

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.

0reactions
jespanagcommented, Mar 4, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with duplicates - EndNote
De-duplication tool · Go to the Library menu and select Find Duplicates. · Compare duplicate references to decide which to keep. · If...
Read more >
Dealing with duplicates - Mendeley Desktop
Go to the Tools menu and select Check for Duplicates. Sets of duplicate references will be displayed. Each set shows what your duplicates...
Read more >
How to Find and Remove Duplicate References in EndNote 20
Open your EndNote library; Click All References; Click the Library menu on the top; Move your cursor to Find Duplicates (the 3rd option...
Read more >
Importing and Indentifying Duplicates - Covidence
Covidence will try to identify duplicate references. View the duplicates from the Imports >> Manage Imports page. Click "Check Duplicates" under ...
Read more >
Why duplicate reference tables are created when importing ...
To resolve this issue, you could purge the duplicate reference tables by using the infacmd command. This will purge only the tables for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found