3

I have a project written in C# targetting .NET version 4.6.1 on Windows that I'm also compiling with mcs on mono 4.2.1 on Debian Jessie.

The command I use to compile the program is

mcs -define:LINUX -langversion:experimental -platform:x64 -recurse:'*.cs' -optimize+ -r:$DLLS -out:$CURRENTDIR/program.exe

where $DLLS is a list of DLLs in $CURRENTDIR.

What bothers me is that the compiler throws the following warning. The program works as expected, but I'm clueless as to why this warning appears and how I can potentially fix it.

warning CS1701: Assuming assembly reference `Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' matches assembly `Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. You may need to supply runtime policy
Compilation succeeded - 1 warning(s)

All lines referencing Newtonsoft.Json in the project

$ grep -rh Newtonsoft .
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net461" />
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json;

The referenced DLL is version 8.0.0.0 according to these commands recommended in How to get the AssemblyVersion of a .Net file in Linux and I've tried getting the latest version via NuGet on both Windows (via Visual Studio 2015) and Linux via nuget.exe (v3.3.0).

$ monodis --assembly Newtonsoft.Json.dll | grep Version
Version:       8.0.0.0
$ strings Newtonsoft.Json.dll | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
8.0.2.19309

The project originally used Newtonsoft.Json v7, but was updated to 8.0.2 before I ever compiled it under Linux.

Community
  • 1
  • 1
3ventic
  • 1,023
  • 1
  • 20
  • 32
  • Have the exact same problem. Mono JIT compiler version 4.2.2 (Stable 4.2.2.30/996df3c), Monodevelop 5.1, Ubuntu 15.10. – firefly2442 Feb 02 '16 at 22:19
  • Same problem when adding the Newtonsoft.Json 8.0.2 package to the C# project in Visual Studio 2015: Include contains full assembly name for version 8.0.0 and HintPath refers correct version 8.0.0. This leads to runtime issue when 8.0.0 is not found. – Dmitry Voytsekhovskiy Jun 02 '16 at 10:49

0 Answers0