Question

On running a windows phone project in VS 2012, I was getting this error:

    {System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at MobileConnection.SSCClient.SSCConnection.GetHostNameAndPort()
   at MobileConnection.SSCClient.SSCConnection.InitializeSSCConnection(Boolean runningState)}

The corresponding entries in .csproj file is:

    <Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\sl4-windowsphone71\Newtonsoft.Json.dll</HintPath>
</Reference>

And, in packages.config:

  <package id="Newtonsoft.Json" version="4.5.11" targetFramework="wp80" />

I debugged it for a while, re-installed the newtonsoft.json package through nuget.
But the solution that worked for me is setting the 'private' property to 'True'.

Updated entry in .csproj file:

<Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\sl4-windowsphone71\Newtonsoft.Json.dll</HintPath>
   <Private>True</Private>
</Reference>

I am not able to understand how it worked or what the issue was. The description on msdn documentation didn't help much either http://msdn.microsoft.com/en-us/library/vstudio/bb629388.aspx.

Was it helpful?

Solution

When running the program, it pulls in dlls from the output directory. Originally, Newtonsoft.Json wasn't being copied to the output directory, but by specifying Private to True, you told Visual Studio to copy the Newtonsoft.Json dll to the output folder along with your program.

For completeness, the documentation on Private:

Optional boolean. Specifies whether the reference should be copied to the output folder. This attribute matches the Copy Local property of the reference that's in the Visual Studio IDE.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top