0
Fixed

Newtonsoft.json.dll (Windows Mixed Reality - HoloToolkit)

André Ivankio Hauer Ploszaj 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 11

I'm having the Newtonsoft.Json.dll problem with Windows Mixed Reality and their HoloToolkit (https://github.com/Microsoft/MixedRealityToolkit-Unity/releases/tag/2017.2.1.3). I've tried to delete each one at a time, but I get ReflectionTypeLoadException in any way. When I try to attach bolt components, I get only a loading icon on the inspector. When I try to click any Ludiq/Bolt button in the tools menu, I get "InvalidOperationException: Trying to access Ludiq product container before it is initialized."

Empty new project, imported holotoolkit, holotoolkit-examples**, applied the automated project configurations***, and tried to import Bolt. 1.2.3 or 1.3 beta 2. Unity 2017.3.0f3

** https://github.com/Microsoft/MixedRealityToolkit-Unity/releases/tag/2017.2.1.3
*** I guess they automate this: https://docs.microsoft.com/en-us/windows/mixed-reality/holograms-100#chapter-3---setup-the-project-settings (Target Windows Universal, Enable XR, Build for Direct3D, Target Occluded Devices, Enable .NET scripting backend)

Same/similar issue was reported with AWS (Amazon Web Services). I've seen reports that Newtonsoft would conflict only on a build but we couldn't even use bolt in the editor.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
GOOD, I'M SATISFIED
Satisfaction mark by André Ivankio Hauer Ploszaj 3 years ago
Pending Review

Hi André!

Thanks for reporting the issue.

Can you paste the full stack trace for:

  • The ReflectionTypeLoadException
  • The InvalidOperationException

Tried importing Bolt 1.3.0 Beta 3 after HoloToolkit:

error CS1703: An assembly `Newtonsoft.Json' with the same identity has already been imported. Consider removing one of the references
Assets/HoloToolkit/Utilities/Scripts/GLTF/Plugins/JsonNet/Newtonsoft.Json.dll (Location of the symbol related to previous error)
Assets/Ludiq/Assemblies/Newtonsoft.Json.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings


Removed Newtonsoft.Json.dll file (and later .xml and .defines with the same outcome) in Ludiq/Assemblies:

FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:59)
System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:75)
System.Reflection.MonoMethod.get_Attributes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:245)
System.Reflection.MethodBase.get_IsSpecialName () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:184)
UnityEditor.Build.BuildPipelineInterfaces.InitializeBuildCallbacks (BuildCallbacks findFlags) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:191)
ReflectionTypeLoadException: The classes in the module cannot be loaded.
System.Reflection.Assembly.GetTypes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:371)
Ludiq.RuntimeCodebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/RuntimeCodebase.cs:40)
Rethrow as Exception: Failed to load types in assembly 'SharpRaven, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Ludiq.RuntimeCodebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/RuntimeCodebase.cs:44)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ludiq.RuntimeCodebase
Ludiq.Codebase.SerializeType (System.Type type) (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Reflection/Codebase.cs:167)
Ludiq.Codebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Reflection/Codebase.cs:92)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ludiq.Codebase
Ludiq.PluginContainer.Initialize () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Plugins/PluginContainer.cs:77)
UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at


Trying to click something in the Tools menu > Ludiq

InvalidOperationException: Trying to access Ludiq product container before it is initialized.
Ludiq.ProductContainer.EnsureInitialized () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Products/ProductContainer.cs:94)
Ludiq.ProductContainer.GetProduct (System.String productId) (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Products/ProductContainer.cs:121)
Ludiq.LudiqProduct.get_instance () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Product/LudiqProduct.cs:26)
Ludiq.LudiqProduct.HookEditorPreferences () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Product/LudiqProduct.cs:75)

This is what I get if I delete the HoloToolkit's Newtonsoft and leave Bolt intact:

ReflectionTypeLoadException: The classes in the module cannot be loaded.
System.Reflection.Assembly.GetTypes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:371)
Ludiq.RuntimeCodebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/RuntimeCodebase.cs:40)
Rethrow as Exception: Failed to load types in assembly 'GLTFSerialization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Ludiq.RuntimeCodebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/RuntimeCodebase.cs:44)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ludiq.RuntimeCodebase
Ludiq.Codebase.SerializeType (System.Type type) (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Reflection/Codebase.cs:167)
Ludiq.Codebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Reflection/Codebase.cs:92)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ludiq.Codebase
Ludiq.PluginContainer.Initialize () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Plugins/PluginContainer.cs:77)
UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:136)

Hi André,

If it is literally the same identity, this is good news, it means that the two DLL's are actually the same version.

I would try removing Bolt's Newtonsoft.Json.dll, then restarting Unity.

The DLL is located at Plugins/Assemblies in v.1.2.x and Ludiq/Assemblies in v.1.3+.

Then, make sure that the remaining DLL in your project is set to compile for all platforms, including editor. (You can edit this easily from the DLL file's inspector).

Let me know if you still get issues after this!

After deleting Ludiq\Assemblies\Newtonsoft.json.dll and restarting. The file not found is shorter. Same Reflection error

FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.

I'll try to move stuff around some more (WMR change some project settings, including stuff I know nothing about but I've seen talked about in Bolt .NET 3.5, 4.6, 2.0 subnet, ILCPP), but so I know: I should have to delete only the .dll file or also .define and .xml with the same name?

Doesn't seem tied to project settings after all. The problem occur even if:
Empty new project, imported Bolt, setup Bolt, import holotoolkit without including their Newtonsoft.json.dll. The reflection error and broken Bolt appears immediately even before I have a chance to apply the suggested project settings.

This way I get these errors:

1
 System.Object& result) [0x00032] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:851 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x00159] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:826 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_2_Version (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x0011c] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:730 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x00049] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:675 
  at Ludiq.FullSerializer.fsSerializer.TryDeserialize (Ludiq.FullSerializer.fsData data, System.Type storageType, System.Type overrideConverterType, System.Object& result) [0x0003d] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:628 
  at Ludiq.Serialization.DeserializeJson (Ludiq.FullSerializer.fsSerializer serializer, System.String json, System.Object& instance, Boolean forceReflected) [0x0000a] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Serialization\Serialization.cs:166 
  at Ludiq.Serialization.DeserializeInto (SerializationData data, System.Object& instance, Boolean forceReflected) [0x0002e] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Serialization\Serialization.cs:113 
  --- End of inner exception stack trace ---
  at Ludiq.Serialization.DeserializeInto (SerializationData data, System.Object& instance, Boolean forceReflected) [0x0007f] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Serialization\Serialization.cs:127 
  at Ludiq.LudiqScriptableObject.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () [0x00010] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Unity\LudiqScriptableObject.cs:48  2 System.Exception: Package directory not found: "C:\Users\Andre\.nuget\packages\Microsoft.CSharp\4.0.1".
  at UnityEditor.Scripting.Compilers.NuGetPackageResolver.Resolve () [0x000dd] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
  at AssemblyUpdater.Core.AssemblyUpdaterContext.AddFrameworkFolderToSearchPath (Mono.Cecil.AssemblyDefinition assemblyDefinition, Mono.Cecil.DefaultAssemblyResolver resolver, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x000eb] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
  at AssemblyUpdater.Core.AssemblyUpdaterContext.ReadAssembly (System.String assemblyPath, APIUpdater.Framework.Log.IAPIUpdaterListener listener, System.IO.FileAccess mode, System.String[] searchPaths) [0x0007a] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
  at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, APIUpdater.Framework.Configuration.IConfigurationProvider configuration, System.String[] assemblySearchPaths, AssemblyUpdater.Core.UpdaterMode mode, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x0002b] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
  at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, System.String[] assemblySearchPaths, AssemblyUpdater.Core.UpdaterMode mode, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00001] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
  at AssemblyUpdater.Application.Program.CheckForObsoleteAPIUsage (AssemblyUpdater.Application.CommandLineSpec config) [0x00013] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
  at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00057] in <3f368bacb6c34f4db5fe7e90570f303a>:0 
UnityEditor.Scripting.APIUpdaterHelper:DoesAssemblyRequireUpgrade(String) 3 Failed to deserialize scriptable object.
System.Runtime.Serialization.SerializationException: Deserialization into 'Bolt.VariablesAsset' failed. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Ludiq.MemberUtility ---> System.TypeInitializationException: An exception was thrown by the type initializer for Ludiq.RuntimeCodebase ---> System.Exception: Failed to load types in assembly 'GLTFSerialization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. ---> 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 /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:371 
  at Ludiq.RuntimeCodebase..cctor () [0x00062] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Reflection\RuntimeCodebase.cs:40 
  --- End of inner exception stack trace ---
  at Ludiq.RuntimeCodebase..cctor () [0x0006e] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Reflection\RuntimeCodebase.cs:44 
  --- End of inner exception stack trace ---
  at Ludiq.MemberUtility..cctor () [0x00000] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Reflection\MemberUtility.cs:18 
  --- End of inner exception stack trace ---
  at Ludiq.OptimizedReflection.GetPropertyAccessor (System.Reflection.PropertyInfo propertyInfo) [0x00026] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Reflection\Optimization\OptimizedReflection.cs:226 
  at Ludiq.OptimizedReflection.SetValueOptimized (System.Reflection.PropertyInfo propertyInfo, System.Object target, System.Object value) [0x00000] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Reflection\Optimization\OptimizedReflection.cs:198 
  at Ludiq.FullSerializer.fsMetaProperty.Write (System.Object context, System.Object value) [0x00046] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\Reflection\fsMetaProperty.cs:131 
  at Ludiq.FullSerializer.fsReflectedConverter.TryDeserialize (Ludiq.FullSerializer.fsData data, System.Object& instance, System.Type storageType) [0x000b3] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\Converters\fsReflectedConverter.cs:105 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_5_Converter (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type resultType, System.Object& result) [0x0001a] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:861 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_4_Cycles (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type resultType, System.Object& result) [0x00032] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:851 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x00159] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:826 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_2_Version (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x0011c] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:730 
  at Ludiq.FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference (System.Type overrideConverterType, Ludiq.FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x00049] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:675 
  at Ludiq.FullSerializer.fsSerializer.TryDeserialize (Ludiq.FullSerializer.fsData data, System.Type storageType, System.Type overrideConverterType, System.Object& result) [0x0003d] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Dependencies\FullSerializer\fsSerializer.cs:628 
  at Ludiq.Serialization.DeserializeJson (Ludiq.FullSerializer.fsSerializer serializer, System.String json, System.Object& instance, Boolean forceReflected) [0x0000a] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Serialization\Serialization.cs:166 
  at Ludiq.Serialization.DeserializeInto (SerializationData data, System.Object& instance, Boolean forceReflected) [0x0002e] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Serialization\Serialization.cs:113 
  --- End of inner exception stack trace ---
  at Ludiq.Serialization.DeserializeInto (SerializationData data, System.Object& instance, Boolean forceReflected) [0x0007f] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Serialization\Serialization.cs:127 
  at Ludiq.LudiqScriptableObject.UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize () [0x00010] in C:\Users\lazlo\Projects\Ludiq\Ludiq.Core\Runtime\Unity\LudiqScriptableObject.cs:48 4 ReflectionTypeLoadException: The classes in the module cannot be loaded.
System.Reflection.Assembly.GetTypes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:371)
Ludiq.RuntimeCodebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/RuntimeCodebase.cs:40)
Rethrow as Exception: Failed to load types in assembly 'GLTFSerialization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Ludiq.RuntimeCodebase..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/RuntimeCodebase.cs:44)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ludiq.RuntimeCodebase
Ludiq.MemberUtility..cctor () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Runtime/Reflection/MemberUtility.cs:18)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Ludiq.Codebase
Ludiq.PluginContainer.Initialize () (at C:/Users/lazlo/Projects/Ludiq/Ludiq.Core/Editor/Plugins/PluginContainer.cs:77)
UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:136)


I don't think I'll be able to brute force my way out of this issue. Testing, changing some random thing and retesting. I'll really need your help that know what those dependencies are for.


Off topic and just for the records, recently when first installing Bolt's package on an empty project in my system (either 1.3.0 beta 3 or 1.2.3), the setup freezes Unity on the generate units part. Restarting Unity with the project prompts the setup process to run correctly. I started using Visual Studio 2017 instead of 2015.

Hi André,

This is odd, it seems that Unity is unable to look for the DLL in other places than the current directory, but will try to anyway when there are both... Probably a problem with their assembly lookup directories.

I'm not sure how to fix that, but the good news is that I think I can get rid of the Newtonsoft (and SharpRaven) dependencies altogether. They were used for an early prototype of automated error reporting, but it isn't used at the moment and only causes bloat and errors.

Fixed in Beta

It appears to have worked! 2 dependencies gone, no change in functionality whatsoever. :)

Bolt will no longer ship with Newtonsoft.Json.dll starting in v.1.3.0b4.

I confirm it plays very nicely with HoloToolkit. Thank you!