locked
You must add a reference to assembly RRS feed

  • Question

  • User3774 posted

    When I try to build my MonoDroid project, I get following errors:

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

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

    Can you please help me with this?

    Thursday, February 28, 2013 12:06 PM

All replies

  • User3774 posted

    Just to add that this is a problem that occurs when I try to reference object from Portable Class Library

    Thursday, February 28, 2013 2:42 PM
  • User29580 posted

    Did you find a solution to this problem?

    Thursday, May 28, 2015 2:39 PM
  • User209 posted

    This problem was solved long ago. However, I've seen some people having troubles with this again in Visual Studio 2015. What is your environment like @MarkDownes?

    Friday, May 29, 2015 6:49 AM
  • User29580 posted

    I'm trying to bind to a native Java .jar and when I compile the binding project I get the following exception: Error 74 The type 'System.Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Apparently one of the auto-generated types contains an Enum. When I go to Add Reference System.Runtime is not available.

    Tuesday, June 2, 2015 8:58 PM
  • User54846 posted

    Any update to this? I am having this issue with VS2015 RC on Windows 10 Enterprise

    Saturday, July 4, 2015 7:59 PM
  • User75222 posted

    Problem here too! VS 2015 RTM and Windows 10 RTM

    Thursday, July 23, 2015 9:48 AM
  • User144910 posted

    I have the same problem vs 2015 RTM

    Thursday, July 30, 2015 10:47 AM
  • User1875 posted

    Same problem here (VS 2015, Xamarin.Forms project on Android). Can we get a solution to this issue or at least a workaround?

    Friday, July 31, 2015 2:08 PM
  • User147838 posted

    Same problem here. VS2015 Native Portable Project

    Thursday, August 6, 2015 7:25 AM
  • User115277 posted

    Just installed VS2015 got 2000 errors with the "The type'...' is defined in an assembly that is not referenced"... using Win 7.

    Thursday, August 6, 2015 8:26 AM
  • User115277 posted

    Also when I later tryied to use VS2013 again all the Xamarin projects were incompatible. To solve that i had to right click Xamarin in Add/Remove program and select Change. Then i could install Xamarin for vs2013 again. Just downloading and installing the normal way did not help.

    Thursday, August 6, 2015 9:02 AM
  • User67586 posted

    Same here :-/ with VS 2015. Same solution in VS 2013 works fine. Strange: I saw that the Errors only come from the IntelliSense...when i comile the solution, the are no build erros

    Thursday, August 6, 2015 11:25 AM
  • User147983 posted

    @OliverMelcher exactly what I'm facing.

    Thursday, August 6, 2015 4:55 PM
  • User67586 posted

    For me it happens in the combination: Xamarin (Android) Project with a references to a PCLs (all with target profile 111: .NET Framework 4.5, Windows 8, Windows Phone 8.1, Xamarin.Android, Xamarin.iOS, Xamarin.iOS (Classic) )

    Using the same PCLs in a "non Xamarin" project (e.g. WinForms) works fine...no IntelliSense errors.

    Friday, August 7, 2015 7:29 AM
  • User1875 posted

    In my case the solution doesn't compile at all. If I open the very same solution with Xamarin Studio on a Mac, it works just fine.

    Tuesday, August 11, 2015 8:52 AM
  • User67586 posted

    Today i tried to add the missing reference(s) manually by opening the projects .csproj file in a text editor, since it is not possible to add them via "Add Reference.." (they don't appear in the list but they exist, seems to be a problem with the framework-version-filter!?)

    And voila: everything works fine, no more IntelliSense errors... Project successfully compiled an deployed to device.

    I had to add the following lines, but it depends on what you've referenced in your PCLs

    <Reference Include="System.Runtime" />
    <Reference Include="System.Globalization" />
    <Reference Include="System.ObjectModel" />
    <Reference Include="System.Net.Primitives" />
    
    Monday, August 17, 2015 2:59 PM
  • User11072 posted

    @OliverMelcher Your solution solved my problem. Thank you for posting what worked for you. You saved me a ton of time.

    Wednesday, August 19, 2015 2:35 AM
  • User67586 posted

    @KevinFord I'm happy to hear that.

    But: Since it seems to be only an IntelliSense problem, it's a workaround with a bad taste. Because the added references aren't really necessary...

    It would be nice to get an official statement to this. Hello, Xamarin-Team...?

    Wednesday, August 19, 2015 7:47 AM
  • User114763 posted

    I have the same problem, VS2015 and Windows 10. I agree with @OliverMelcher, adding "dummy" references should only be considered as an emergency band-aid, not a workaround.

    EDIT: This worked for me, for some reason I had to restart Visual Studio twice to get rit of the errors. https://bugzilla.xamarin.com/show_bug.cgi?id=32622

    Wednesday, August 19, 2015 10:04 AM
  • User11072 posted

    @OliverMelcher My experience leads me to believe that this will be fixed by the Xamarin team so I'm not overly worried about that. Until then it is just a bit of a PITA and your workaround has probably saved a lot of us significant headaches.

    Wednesday, August 19, 2015 12:50 PM
  • User209 posted

    When building in VS2015, in the dropdown box down in the Error List window where it says Build + Intellisense switch it over to Build Only and see the errors disappear and you are able to build again.

    Wednesday, August 19, 2015 4:13 PM
  • User73524 posted

    @OliverMelcher - thanks. Adding reference hints fixed the intellisense errors for me as well.

    Friday, August 21, 2015 3:18 AM
  • User123942 posted

    I had a similar error when attempting to leverage MvvmCross in VS2015, my issue was with the System.Linq.Extensions library not being properly referenced, in addition to IntelliSense incorrectly flagging System.Runtime as a missing reference. All projects built fine using Xamarin Studio in Win and Mac; actually, although there were IntelliSense errors in VS2015, the project was able to build so long as I didn't try to resolve any of the missing references.

    When building in VS2015, in the dropdown box down in the Error List window where it says Build + Intellisense switch it over to Build Only and see the errors disappear and you are able to build again.

    Thanks Tomasz, this fixed my environment. Looks like there is an issue with VS2015 IntelliSense being able to correctly map the Xamarin implementation.

    Tuesday, August 25, 2015 8:35 PM
  • User153717 posted

    @OliverMelcher - Thanks!

    Thursday, August 27, 2015 2:02 PM
  • User130239 posted

    @OliverMelcher , that's perfect, thanks! The most important message though I think is that this is JUST AN INTELLISENSE problem (well and a Visual Studio UI problem since even on the References folder it shows a little warning sign and the properties for those files are missing information).

    If you ignore it and build the project it should still work.

    Having said that, it's really bad that you can't trust build error messages and the advice to devs is just "ignore it". This makes Xamarin look like a broken immature product so it should be really high in the Xam team bug fixing priority in my opinion.

    Wednesday, October 7, 2015 11:11 AM
  • User47710 posted

    Ever since upgrading to VS2015 I've been having the same Intellisense issues.

    Recently one of those errors went from fictitious to real and was preventing a build. Following @OliverMelcher solution I was able to get rid of the Intellisense errors and a real problem that was hiding among all those "errors"....

    Wednesday, October 14, 2015 4:45 PM
  • User48000 posted

    I am also experiencing build errors. After upgrading to VS.NET 2015 I can still compile my PCL's (Profile111) and some of my Android libraries, despite the IntelliSense errors. However one of my Android projects does not compile. It contains a class that is derived from a class in a PCL library. This class overrides a a method that returns a System.IO.Stream. In my build errors (not IntelliSense!) there is a message saying "The type 'Stream' is defined in an assembly that is not referenced" and also a message "return type must be 'Stream' to match overridden member". Same kind of problems arise with System.Threading.Tasks, etc.

    Anyone found a solution yet? EDIT: I solved it by removing my hidden .vs folder (again) and removing references to System.ObjectModel and System.Runtime from the Android project.

    Tuesday, October 27, 2015 11:30 AM
  • User164561 posted

    Thanks a lot @OliverMelcher . You save me to became crazy !

    Tuesday, November 3, 2015 3:17 PM
  • User203024 posted

    Thanks @OliverMelcher, this solution work for me

    Wednesday, October 12, 2016 6:26 AM
  • User311641 posted

    @OliverMelcher said: Today i tried to add the missing reference(s) manually by opening the projects .csproj file in a text editor, since it is not possible to add them via "Add Reference.." (they don't appear in the list but they exist, seems to be a problem with the framework-version-filter!?)

    And voila: everything works fine, no more IntelliSense errors... Project successfully compiled an deployed to device.

    I had to add the following lines, but it depends on what you've referenced in your PCLs

    <Reference Include="System.Runtime" />
    <Reference Include="System.Globalization" />
    <Reference Include="System.ObjectModel" />
    <Reference Include="System.Net.Primitives" />
    

    It is March 2017 and still this tick is needed. Thank you Oliver.

    Friday, March 24, 2017 9:05 AM
  • User177092 posted

    Thanks a lot @OliverMelcher , it worked for me.

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

    Steps: 1. Open the .csproj file in a text editor , and add below reference manually. <Reference Include="System.Runtime" />

    2. Close the project and restart it

    Tuesday, April 11, 2017 7:36 AM
  • User259531 posted

    Thanks @OliverMelcher ! Worked for iOS binding project in VisualStudio for Mac

    Tuesday, June 6, 2017 12:52 AM
  • User329436 posted

    I got the same error, and I believe it happend after updating Xamarin Studio and some packages (didn't check which). For me the error pointed to JsonConvert from the Json.NET package. So after reading through this and not liking the workaround I simply removed the Json.Net package from my solution and re-added it. This resolved the error for me.

    Thursday, June 8, 2017 8:05 PM
  • User78729 posted

    I found this solution - YMMV : https://stackoverflow.com/questions/32607616/visual-studio-2015-c-sharp-windows-universal-app-missing-assembly-reference

    Saturday, June 10, 2017 3:44 PM