Newtonsoft.Json.dll compilation problems #187

Closed
MihaMarkic opened this Issue Mar 13, 2013 · 12 comments

Comments

Projects
None yet
5 participants
Contributor

MihaMarkic commented Mar 13, 2013

One more problem when compiling v3 samples - I am getting the error below. Any idea how to workaround? Perhaps using Newtonsoft.Json.dll sources?

Error 172 Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Newtonsoft.Json.dll'
at Monodroid.Tuner.MonoDroidResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 assemblies, AssemblyDefinition assembly)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() TestOne

Contributor

slodge commented Mar 13, 2013

I've seen this on one customer machine

Not sure what is causing it, and customer was too non-technical to help.

Basically, something in your VS setup is forcing CopyLocal for the PCL newtonsoft.json to false

If you set it to true, then it will compile - but I'd like to identify why it is being forced to false. Can you see any reason?

Contributor

MihaMarkic commented Mar 13, 2013

Good hint. I've created a new android app within your solution and referenced CrossCore, CrossCore.Droid, MvvmCross, MvmCross.Binding, MvmCross.Binding.Droid MvvmCross.Droid and MvmCross.Plugins.Json.
Initially I got that error but once I set CopyLocal=true for NewtonSoft.Json.dll in MvmCross.Plugins.Json references the error went away.
However it still remains for samples. WIll do some more tests.

Contributor

slodge commented Mar 13, 2013

Thanks

I did think it was maybe due to something from MS (or from Xam?) installing a copy of Newtsonsoft in the GAC - but I didn't get to the bottom of it.

There may be some setting to force CopyLocal in the project file - but VS and XS seemed to fight me :/

Contributor

MihaMarkic commented Mar 13, 2013

Update
If I have an empty project and reference Json it will work but as soon as I call one of its methods it would file at compile time.
i.e. Cirrious.MvvmCross.Plugins.Json.PluginLoader.Instance.EnsureLoaded();
Looks like compiler ignores it if not need (makes sense).

Contributor

MihaMarkic commented Mar 13, 2013

Solved by adding Newtonsoft.Json sources instead of referencing the library.
http://blog.rthand.com/post/2013/03/13/How-to-compile-MvvmCross-v3-sources.aspx

Contributor

slodge commented Mar 13, 2013

Any idea if there is any flag I can put in the csproj file to force it to copy local? Maybe I need to set the Specific Version? (although that would suck)

Contributor

MihaMarkic commented Mar 13, 2013

Click on reference, CopyLocal=true in reference properties. That's it. It don't think it is related to specific version in any way. But even when copied locally the problems persisted for me.

Contributor

slodge commented Apr 12, 2013

The good news (sad news) is that Newtonsoft is not really needed for quite a lot of samples now....

The bad news is that I think this property still isn't persisted correctly in the project settings...

So leaving this open for now...

Contributor

slodge commented May 17, 2013

I don't believe this as much of a problem any more - certainly not in this repo anyway.

Closing this - hopefully it's covered by the new nuget approach.

If not then I'm sure it will reopen...

slodge closed this May 17, 2013

rbellio commented Jan 30, 2014

I'm still receiving the issue, even while utilizing "Copy Local" to "True" as well as referencing it from nuget. Am I doing something wrong that no one else has commented on this in nine months?

I get this error as well

lvialle commented Jan 25, 2015

if you get this issue, uncheck "Local Copy" and Recheck it, it seems to be a bug with the default value. It should work at least withing Xamarin Studio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment