的Visual Studio 2012项目 - 无法加载“Newtonsoft.Json” [英] Visual studio 2012 project - Not able to load 'Newtonsoft.Json'

查看:2174
本文介绍了的Visual Studio 2012项目 - 无法加载“Newtonsoft.Json”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS中运行2012在Windows手机项目中,我得到这个错误:

On running a windows phone project in VS 2012, I was getting this error:

    {System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at MobileConnection.SSCClient.SSCConnection.GetHostNameAndPort()
   at MobileConnection.SSCClient.SSCConnection.InitializeSSCConnection(Boolean runningState)}

在.csproj的文件中相应的条目是:

The corresponding entries in .csproj file is:

    <Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\sl4-windowsphone71\Newtonsoft.Json.dll</HintPath>
</Reference>

和,在packages.config:

And, in packages.config:

  <package id="Newtonsoft.Json" version="4.5.11" targetFramework="wp80" />



我调试了一段时间,再通过安装在的NuGet包newtonsoft.json。结果
但是,这为我工作的解决方法是设置私人属性设置为真。在.csproj的

更新的条目文件:

<Reference Include="Newtonsoft.Json">
  <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\sl4-windowsphone71\Newtonsoft.Json.dll</HintPath>
   <Private>True</Private>
</Reference>



我不能够理解它是如何工作或者是什么问题了。 // MSDN:在MSDN文档的描述并没有太大要么 HTTP帮助。 microsoft.com/en-us/library/vstudio/bb629388.aspx

推荐答案

在运行程序,它拉从输出目录中的DLL。原来, Newtonsoft.Json 没有被复制到输出目录,但通过指定私人,你告诉Visual Studio中的 Newtonsoft.Json DLL与程序一起复制到输出文件夹。

When running the program, it pulls in dlls from the output directory. Originally, Newtonsoft.Json wasn't being copied to the output directory, but by specifying Private to True, you told Visual Studio to copy the Newtonsoft.Json dll to the output folder along with your program.

有关完整性,民营文档:

For completeness, the documentation on Private:

可选的布尔值。指定参考是否应该被复制到输出文件夹。此属性这是在Visual Studio IDE中引用的复制本地属性相匹配。

Optional boolean. Specifies whether the reference should be copied to the output folder. This attribute matches the Copy Local property of the reference that's in the Visual Studio IDE.

这篇关于的Visual Studio 2012项目 - 无法加载“Newtonsoft.Json”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆