0

I'm working on a project where I need Microsoft azure SDKs and Autodesk NuGet package as well, the issue is that when I install Autodesk forge Nuget I receive an error regarding with 'The type 'JsonConvert' exists in both 'Newtonsoft.Json'. When I checked the reference object browser I got there are 2 versions Newtonsoft, one of that 6.0 refers to Microsoft azure sdk.

I tried to remove older version from .csproj but did not found.

enter image description here

here is the object browser screen below

enter image description here

error I'm getting is

The type 'JsonConvert' exists in both 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' and 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

any suggestion to solve it, I do tried to check dependencies of both package but one do need Newtonsoft version greater than 10 and other still refer only 6.0

Edit : Got solution so adding here what I refered

Dark S
  • 308
  • 2
  • 15
  • hm.. are you using nuget / nuget packages? – sommmen Apr 13 '20 at 09:40
  • This typically happens when another library has done something obnoxious, such as import the source directly as part of their build, or used IL-merge to bind the assembly post-compile. Unfortunately, it is a complete PITA. The best option is to contact whoever supplied the obnoxious DLL and tell them they're being dumb, and to please use package references like everyone else. The hard workaround is "extern alias", but that is *really* hard to work with. – Marc Gravell Apr 13 '20 at 09:45
  • @sommmen one is nuget and onother one is SDK – Dark S Apr 13 '20 at 09:50
  • @MarcGravell yes, is really a pain in the head now, as after being successfully representing demo with approval when it comes to integrating it to the main source everything stuck because of conficts – Dark S Apr 13 '20 at 09:53

1 Answers1

1

This situation can be resolved by using an alias name for one (or both) of the conflicting assemblies.

A similar question has been answered here: Assembly names conflict on external dependencies.

You need to do two steps:

  1. Give the assembly an alias name (by selecting Properties in the Object Browser)
  2. Use the keyword extern alias <alias-name>; in your code

An example is given in the above-mentioned similar question.

This is also explained in the documentation by Microsoft: extern alias. It introduces a parallel global namespace.

lzydrmr
  • 867
  • 5
  • 7
  • thanks for the info, means I have to dig it through now. I will update if any issue occurs further. – Dark S Apr 13 '20 at 13:22
  • 1
    Here is another mentioning of the problem, with an explanation of the solution: [two different DLL with same namespace](https://stackoverflow.com/questions/3672920/two-different-dll-with-same-namespace/3672987) – lzydrmr Apr 13 '20 at 15:46
  • thanks! I referred to this one [extern-alias](https://blogs.msdn.microsoft.com/ansonh/2006/09/27/extern-alias-walkthrough/) errors gone, have to test it throughout now – Dark S Apr 14 '20 at 06:13