无法加载文件或程序集“Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed"或其依赖项之一

Could not load file or assembly #39;Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed#39; or one of its dependencies(无法加载文件或程序集“Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed或其依赖项之一) - IT屋-

本文介绍了无法加载文件或程序集“Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed"或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以前使用 VS 2013 在 Windows 8.1 上构建的 WinJS 项目.

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、SQLite for Universal Windows Platform、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:

System.IO.FileNotFoundException"类型的异常发生在 mscorlib.ni.dll 中,但未在用户代码中处理.

附加信息:无法加载文件或程序集Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"或其依赖项之一.系统找不到指定的文件.

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.

推荐答案

我做了一个基本的Demo,重现了这个问题.似乎 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:

  1. 右键引用->添加引用->浏览...->找到C:Users.nugetpackagesNewtonsoft.Json9.0.1libportable-net45+wp80+win8+wpa81Newtonsoft.json.dll->点击添加按钮.

  1. Right click References-> Add Reference->Browse...-> Find C:Users.nugetpackagesNewtonsoft.Json9.0.1libportable-net45+wp80+win8+wpa81Newtonsoft.json.dll->Click Add button.

重建您的运行时组件项目并运行.这个错误应该消失了.

Rebuild your Runtime Component project and run. This error should be gone.

这篇关于无法加载文件或程序集“Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:无法加载文件或程序集“Newtonsoft.Json,Version=9.0.0.0,Culture=neutral,PublicKeyToken=30ad4fe6b2a6aeed"或其依赖项之一

基础教程推荐