JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.84k stars 3.27k forks source link

Exception when building for windows store WUA #947

Closed flashmandv closed 8 years ago

flashmandv commented 8 years ago

HI, I'm trying to build my game for windows store, but the newtonsoft json fails to build. I tried many different versions and branches and they all throw exception. I'm using Unity 5.4.0 beta + VS 2015 community edition. Here is the error:

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 

The following assembly referenced from E:\PROJECTS\Game\Assets\plugins\Newtonsoft.Json.dll could not be loaded:
     Assembly:   System.Runtime    (assemblyref_index=0)
     Version:    4.0.0.0
     Public Key: b03f5f7f11d50a3a
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (E:\PROJECTS\Game\Assets\plugins\).

Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Missing method .ctor in assembly E:\PROJECTS\Game\Assets\plugins\Newtonsoft.Json.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
Can't find custom attr constructor image: E:\PROJECTS\Game\Assets\plugins\Newtonsoft.Json.dll mtoken: 0x0a00000f

When using other version of the library I get this:

UnityException: Failed to run serialization weaver with command "Temp\StagingArea\Data\Managed\Newtonsoft.Json.dll" 
....
Symbols will be read from Temp\StagingArea\Data\Managed\UnityEngine.pdb
No symbols for Temp\StagingArea\Data\Managed\Newtonsoft.Json.dll
Weaving assembly E:\PROJECTS\LAN.bg\CLIENTS\RentoMonopolyUnity\Temp\StagingArea\Data\Managed\Newtonsoft.Json.dll
 + Newtonsoft.Json.JsonException
 + Newtonsoft.Json.JsonWriterException
 + Newtonsoft.Json.JsonReaderException
 + Newtonsoft.Json.JsonSerializationException
 + Newtonsoft.Json.Schema.JsonSchemaException
Will export symbols of pdb format
Mono.Cecil.ResolutionException: Failed to resolve System.Runtime.Serialization.Formatters.FormatterAssemblyStyle
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
....

I also tried to install it using nuget package manager but then I get:

Could not install package 'Newtonsoft.Json 9.0.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5,Profile=Unity Full v3.5', but the package does not contain any assembly references or content files that are compatible with that framework.

Please help :(

JamesNK commented 8 years ago

I don't support Mono/Unity. There are versions of Newtonsoft.Json that other have made that do.