我刚刚在Unity的资产商店购买了“YouTube移动视频播放器”插件,但是当我导入插件时,我发现这个错误,这就迫使我从我的项目中删除插件。
导入时出现以下错误:
Unhandled Exception: System.TypeLoadException: Could not load type 'Newtonsoft.Json.Linq.JObject' from assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
Newtonsoft.Json是YouTube插件的依赖项,因此如果没有DLL,我就无法运行它。
我尝试在他们的网站上下载几个版本的Newtonsoft.Json,但我无法摆脱TypeLoadException。
我在Linux上使用Unity3D 5.2.3f1,但我不认为这是问题所在。
插件的链接:https://www.assetstore.unity3d.com/en/#!/content/29704 Newtonsoft.Json的链接:http://www.newtonsoft.com/json
有人可以帮助我摆脱这种异常吗?
编辑:如果我尝试将插件导入空白项目,我会收到该错误
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 :0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in :0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in :0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in :0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in :0
at Mono.CSharp.Driver.Compile () [0x00000] in :0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in :0
The class System.ComponentModel.INotifyPropertyChanging could not be loaded, used in System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
The class System.ComponentModel.AddingNewEventHandler could not be loaded, used in System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
The class JTokenReferenceEqualityComparer could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class Newtonsoft.Json.Linq.JContainer could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class Newtonsoft.Json.Linq.JObject could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class Newtonsoft.Json.Linq.JContainer could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class Newtonsoft.Json.Linq.JContainer could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class Newtonsoft.Json.Linq.JContainer could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class Newtonsoft.Json.Linq.JObject could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class d__4`2 could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class d__f`2 could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class d__0 could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class d__2 could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
The class c__DisplayClass2 could not be loaded, used in Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
答案 0 :(得分:1)
假设您的软件包已包含正确的DLL文件并且您将它们放入插件文件夹中,您还可以检查项目设置 - >其他设置 - > Api兼容级别并将其设置为.Net 2.0 Full。如果你可以,在Windows上试试,Unity on Linux可能仍有问题,但一般来说,如果它在资产商店,它应该是兼容的。
答案 1 :(得分:0)
解决方案(VS或monodevelop)是否需要引用此DLL?您可能需要做的不仅仅是删除资产文件夹中的DLL。
看这里,
http://docs.unity3d.com/Manual/UsingDLL.html
确保一切正常。不幸的是,我从来没有遇到过第三方dll这个问题。您可能需要这样做(从链接复制粘贴)
为DLL设置调试会话
首先,您应该为DLL准备调试符号。在 MonoDevelop,将构建的文件/bin/Debug/DLLTest.dll.mdb复制到Assets / Plugins文件夹中。在 Visual Studio,执行
程序文件\ Unity \ Editor \ Data \ Mono \ lib \ mono \ 2.0 \ pdb2mdb.exe中 命令提示符,传递\ bin \ Debug \ DLLTest.pdb作为 参数。然后,将转换后的文件\ bin \ Debug \ DLLTest.dll.mdb复制到Assets / Plugins
希望这会有所帮助,祝你好运