xamarin便携式库和Json.net

时间:2013-11-19 15:50:14

标签: json.net xamarin

我无法在便携式库中使用Json.net。我将可移植库设置为使用配置文件4.5 -78。它编译正常,但在运行时,它会抛出文件未找到异常。有没有人遇到同样的问题?

2 个答案:

答案 0 :(得分:6)

Nuget可能会添加对Json.NET的portable-net45+wp80+win8可移植程序集的引用,这与当前版本的Xamarin不兼容。为了使工作正常,您可以手动切换引用以使用portable-net40+sl4+wp7+win8

Switching to compatible portable Json.NET reference

答案 1 :(得分:2)

我对新的Nuget包(Newtonsoft.Json.6.0.1)有同样的问题。为了解决这个问题,我不得不用HintPath替换PCL csproj中的portable-net40+sl5+wp80+win8+monotouch+monoandroid

为此,手动编辑csproj文件,找到此部分:

<Reference Include="Newtonsoft.Json, Version=...">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\portable-net45+wp80+win8\Newtonsoft.Json.dll</HintPath>
</Reference>

并调整DLL的路径。