Compiled mono missing default .NET libraries - System.Object is not defined or imported
Solution 1
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>
Solution 2
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.
Solution 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.
Solution 4
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.).
Solution 5
my project started compiling, when I removed lines
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
from it.
Geesu
Updated on October 02, 2021Comments
-
Geesu over 2 years
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
-
Steve Mitcham over 9 yearsThe original poster is talking about a mono installation that is compiled from scratch, not downloaded via Xamarin, or through the mono installer.
-
Geesu over 9 yearsI wouldn't need the mcs tool. I'm trying to compile mono itself. I'm adding functionality to it that hasn't been completed.