Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiled mono missing default .NET libraries - System.Object is not defined or imported

I've compiled mono on OS X Mavericks following the guide located here: http://www.mono-project.com/docs/compiling-mono/mac/

Now when I compile my application using xbuild I'm getting the following errors:

CSC: error CS0518: The predefined type `System.Object' is not defined or imported
CSC: error CS0518: The predefined type `System.ValueType' is not defined or imported
CSC: error CS0518: The predefined type `System.Attribute' is not defined or imported
CSC: error CS0518: The predefined type `System.Int32' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt32' is not defined or imported
CSC: error CS0518: The predefined type `System.Int64' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt64' is not defined or imported
CSC: error CS0518: The predefined type `System.Single' is not defined or imported
CSC: error CS0518: The predefined type `System.Double' is not defined or imported
CSC: error CS0518: The predefined type `System.Char' is not defined or imported
CSC: error CS0518: The predefined type `System.Int16' is not defined or imported
CSC: error CS0518: The predefined type `System.Decimal' is not defined or imported
CSC: error CS0518: The predefined type `System.Boolean' is not defined or imported
CSC: error CS0518: The predefined type `System.SByte' is not defined or imported
CSC: error CS0518: The predefined type `System.Byte' is not defined or imported
CSC: error CS0518: The predefined type `System.UInt16' is not defined or imported
CSC: error CS0518: The predefined type `System.String' is not defined or imported
CSC: error CS0518: The predefined type `System.Enum' is not defined or imported
CSC: error CS0518: The predefined type `System.Delegate' is not defined or imported
CSC: error CS0518: The predefined type `System.MulticastDelegate' is not defined or imported
CSC: error CS0518: The predefined type `System.Void' is not defined or imported
CSC: error CS0518: The predefined type `System.Array' is not defined or imported
CSC: error CS0518: The predefined type `System.Type' is not defined or imported
CSC: error CS0518: The predefined type `System.Collections.IEnumerator' is not defined or imported
CSC: error CS0518: The predefined type `System.Collections.IEnumerable' is not defined or imported
CSC: error CS0518: The predefined type `System.IDisposable' is not defined or imported
CSC: error CS0518: The predefined type `System.IntPtr' is not defined or imported
CSC: error CS0518: The predefined type `System.UIntPtr' is not defined or imported
CSC: error CS0518: The predefined type `System.RuntimeFieldHandle' is not defined or imported
CSC: error CS0518: The predefined type `System.RuntimeTypeHandle' is not defined or imported
CSC: error CS0518: The predefined type `System.Exception' is not defined or imported

When I used the mono installer on OS X I never received any of these errors.

(I'm building mono because I'm adding functionality to the .NET framework that wasn't completed)

Result of running autogen.sh: https://gist.github.com/Geesu/149332f3f877c891d387 Result of running make: https://gist.github.com/Geesu/4296f7d4c6c368d6986d

like image 593
Geesu Avatar asked Dec 21 '14 22:12

Geesu


3 Answers

If there is a warning similar to:

/lib/mono/4.5/Microsoft.Common.targets:  warning : Unable to find framework corresponding to the target framework moniker '.NETFramework,Version=v2.0'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.

You can override the .NET Framework on the command line:

xbuild /p:TargetFrameworkVersion="v4.0"

You can change your solution:

<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
like image 159
Cat Zimmermann Avatar answered Oct 23 '22 08:10

Cat Zimmermann


I ran into this issue while building YouCompleteMe / OmniSharpServer on Debian unstable (Sid). What's happening is the installed version of mono doesn't have the v4.5.2 Framework assemblies installed, which is what the compiler defaults to when building that solution/project.

Workaround is to specify the targeted framework version as one you have available, or make available the one being targeted (e.g. during your custom compilation).

Cat Zimmermann's response is apt.

like image 8
Nathan Schulte Avatar answered Oct 23 '22 09:10

Nathan Schulte


I stumpled acros this problem to. I forgot to check for updates after rerunning the Mavericks installer, and there were Stable channel updates available for both Mono and Xamarin.Android. Once I installed them, everything built just fine.

like image 3
Sievajet Avatar answered Oct 23 '22 07:10

Sievajet