'Object' is defined in an assembly that is not referenced

In both

  • Visual Studio Mac: Preview 8 (7.0 build 2845)
  • Xamarin Studio (latest, I uninstalled everything and tried reinstalling)

I get this error on build:

Error: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I can solve this problem by manually adding <Reference Include="System.Runtime" /> into my csproj file. I am curious if this is the recommended solution here? Following that I am curious if this is a bug in these 2 programs or it's something else that I need to do setup wise on my system? I was doing Xamarin University and got completely caught up on this issue.

A search though the forums shows other have had similar errors. Why doesn't the project template just add that one line?

Answers

  • AdamVenturellaAdamVenturella USMember ✭✭

    To add to the information here, my issue stems from the use of JsonConvert.DeserializeObject in the XAM110 lesson files. (https://elearning.xamarin.com/forms/xam110/shared-projects/exercise/1-open-starter) Specifically from the Asset: SongLoader.cs in the Load method.

    This relies on the user installing Newtonsoft Json. Once installed the DeserializeObject command has the error.

  • AdamVenturellaAdamVenturella USMember ✭✭

    The plot thickens!

    If I add a PCL Library to the Solution and install Newtonsoft.Json into that PCL then add that project as a reference to my iOS application the error goes away. If I remove the reference to the PCL it comes back.

  • J.TorvaldJ.Torvald SEMember ✭✭

    I had the same, changed my project to hint to a different NewtonSoft Json version:
    <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath> <Private>False</Private> </Reference>

    works for now...

  • @J.Torvald said:
    I had the same, changed my project to hint to a different NewtonSoft Json version:
    <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath> <Private>False</Private> </Reference>

    works for now...

    It's works for my too, Thanks a lot!! .

Sign In or Register to comment.