无法加载文件或程序集"Newtonsoft.Json,版本= 9.0.0.0,区域性=中性,PublicKeyToken = 30ad4fe6b2a6aeed"或其依赖项之一 [英] Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies
问题描述
我有一个WinJS项目,该项目以前是使用VS 2013在Windows 8.1上构建的.
I have a WinJS project that is previously built on Windows 8.1 using VS 2013.
最近,我通过创建一个空白Javascript Universal Windows 10项目将该项目升级到Universal Windows 10,然后添加了旧项目中的所有文件.
Recently I upgraded this project to Universal Windows 10 by creating a blank Javascript Universal windows 10 project and then added all my files from old project.
我有Windows运行时组件,还有SQLite的类库.
I have Windows Runtime Components and also Class Library for SQLite.
我添加了通用Windows运行时组件和通用类库,并将所有文件从旧项目复制到各自的位置.
I added Universal Windows Runtime Component and Universal Class Library and copied all my files from old project to respective places.
我设法以某种方式删除了所有构建错误.
Somehow I managed to remove all the build errors.
我安装了所有必需的SQLite-net,通用Windows平台的SQLite,Newtonsoft等.
I installed all the required SQLite-net, SQLite for Universal Windows Platform, Newtonsoft, etc.
但是,当我运行该应用程序并在Windows运行时组件中调用本机方法时,它会给出一些奇怪的错误,如下所示:
But when I run the application and call a Native method in Windows Runtime Component it gives some kind of strange errors as:
An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code.
Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Newtonsoft版本为:9.0.1
Newtonsoft version is: 9.0.1
我的Windows运行时组件的 project.json 文件具有以下内容:
My project.json file of Windows Runtime Component has following:
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
我的Visual Studio版本是:
My Visual Studio version is:
我尝试删除所有的Newtonsoft json并重新安装,但是没有运气.
I tried removing all the Newtonsoft json and re-installing it but no luck.
推荐答案
我做了一个基本的演示,并重现了这个问题.似乎WinRT组件未能找到Newton.Json
的正确程序集.临时解决方法是手动添加Newtonsoft.json.dll
文件.您可以按照以下步骤来实现:
I made a basic Demo and reproduced this problem. It seems that WinRT component failed to find the correct assembly of Newton.Json
. Temporarily the workaround is to manually add the Newtonsoft.json.dll
file. You can achieve this by following steps:
-
右键单击引用->添加引用->浏览...->查找C:\ Users \ .nuget \ packages \ Newtonsoft.Json \ 9.0.1 \ lib \ portable-net45 + wp80 + win8 + wpa81 \ Newtonsoft.json.dll->单击添加"按钮.
Right click References-> Add Reference->Browse...-> Find C:\Users\.nuget\packages\Newtonsoft.Json\9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.json.dll->Click Add button.
重建您的Runtime Component项目并运行.该错误应该消失了.
Rebuild your Runtime Component project and run. This error should be gone.
这篇关于无法加载文件或程序集"Newtonsoft.Json,版本= 9.0.0.0,区域性=中性,PublicKeyToken = 30ad4fe6b2a6aeed"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!