41

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

Geesu
  • 5,928
  • 11
  • 43
  • 72

9 Answers9

13

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>
Cat Zimmermann
  • 1,422
  • 2
  • 21
  • 38
8

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.

Nathan Schulte
  • 125
  • 2
  • 12
3

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.

Sievajet
  • 3,443
  • 2
  • 18
  • 22
  • 2
    The original poster is talking about a mono installation that is compiled from scratch, not downloaded via Xamarin, or through the mono installer. – Steve Mitcham Dec 31 '14 at 13:35
1

The difference with the installer and the home build is the fact that the installer "knows" where the libarys are located, whereas the compiled one dont. So unless you point to that location when compiling your app, your problem will occure (there are basically no system dll's found). I would recommend looking into the mcs documentation , and specify the path. (EDIT: with the "-L " parameter should do it.).

Kmtdk
  • 184
  • 2
  • 7
  • I wouldn't need the mcs tool. I'm trying to compile mono itself. I'm adding functionality to it that hasn't been completed. – Geesu Dec 31 '14 at 21:36
1

my project started compiling, when I removed lines

<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>

from it.

user1709408
  • 528
  • 4
  • 16
1

I don't know how to back this logically, but after trying to fix this for couple of hours,

Unload .net standards project

because I was not getting the exact problem and decided to

reload it again

boom... It worked... still don't know what is the logical reason behind it. if someone does, please comment below.

Akshay Kulkarni
  • 729
  • 6
  • 22
1

Try deleting bin and obj folders in all projects of that solution.

Seems like those folders were having old files generated by some older version of visual studio, which are not compatible with new version of visual studio.

Jay Shah
  • 3,553
  • 1
  • 27
  • 26
0

I solve this problem by change the project setting->general->Target Framework to Mono/.NET 4.5.

Hope it works for you.

sam
  • 2,049
  • 3
  • 20
  • 27
0

I had the same problem.

I checked my Target Framework Path: Properties>Aplication:Target Framework and set it to .Net Framework 4.7.

XouDo
  • 945
  • 10
  • 19