2

I am trying to upgrade a third party dll, that my project depends on. The dll is Newtonsoft.json.dll.

The current version in the project is 4.5 and I am upgrading to the latest the 6.0.

When I remove the reference, and add the new version, Visual Studio 2013 adds the reference as if it is the old version, even though the dll is correct. This is what is added to my .csproj:

<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
</Reference>

I can edit the .csproj file to (the first one is what I get when referencing the dll from an empty project)

<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
</Reference>

or without requiring a specific version:

<Reference Include="Newtonsoft.Json">
  <HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
</Reference>

My project compiles, but when I run it, I get an error that it cannot find the 4.5 version of the dll referenced. I have gone through all my dependencies, and can't find any references to the old version, and the code that throws the exception is my code, in this project.

I am unsure why Visual Studio cannot resolve the correct version. I am not using NuGet.

I hope someone has a little trick up their sleeve to help me debug this problem. This is really puzzling me, and I am sure it is such a simple thing, but I just can't find it.

Jay Pete
  • 4,123
  • 4
  • 35
  • 51
  • 2
    You should use NuGet. – SLaks Jun 10 '14 at 21:42
  • Do you have Newtonsoft.Json.dll in GAC ? – alex.b Jun 10 '14 at 21:43
  • 1
    `tick [...] to help me debug this problem` - I'd recommend to take `dotPeek` tool and open the compiled project and see the location of referenced Newtonsoft.Json(afaik, dotPeek will try to find referenced dll in similar way as clr does). – alex.b Jun 10 '14 at 21:47
  • I have a Newtonsoft.Json.dll version 3.5 in GAC that a legacy dll I use references. That has never been a problem. I don't have any other versions of it in the GAC. I'll try dotPeek! – Jay Pete Jun 10 '14 at 22:12
  • Turns out that another third party dll, referenced the wrong version. This dll was the reason for my upgrade of NewtonSoft, since this had released a new dll with a reference to the latest version of NewtonSoft. Turns out they hadn't compiled it with the updated version. They use NuGet btw. – Jay Pete Jun 11 '14 at 09:45
  • @aleksey.berezan if you add an answer where you mention dotPeek, I will mark that as the answer. That was exactly the tool I needed to figure out what was going on. – Jay Pete Jun 11 '14 at 09:46
  • @JayPete, glad it helped. Added answer. – alex.b Jun 11 '14 at 16:44
  • Take a look of this reply I gave to a similar question: http://stackoverflow.com/questions/14483550/replacing-dll-to-a-newer-version/14485094#14485094 – Mattia Vitturi Jun 11 '14 at 17:03

1 Answers1

2

I'd recommend to take dotPeek tool and open the compiled project and see the location of referenced Newtonsoft.Json.
As far as I know, dotPeek will try to find referenced dll in similar way as clr does.

Hope this helps.

Community
  • 1
  • 1
alex.b
  • 4,547
  • 1
  • 31
  • 52