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

9

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

Margueritamarguerite answered 21/12, 2014 at 22:22 Comment(6)
Can you post the actual csc line, and locations of it and the built libraries?Reynoso
How can I provide this? I'm not sure how to find the CSC line. Also, I can post the output of the compilation - would that help?Margueritamarguerite
I've added the result of autogen.sh and make aboveMargueritamarguerite
Are those results for building mono, or your app?Reynoso
The gists are of building mono.Margueritamarguerite
Could you post a gist of the entire xbuild output?Faun
F
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>
Faun answered 9/1, 2015 at 7:2 Comment(0)
C
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.

Concentration answered 12/8, 2016 at 16:58 Comment(0)
K
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.

Kirwan answered 30/12, 2014 at 12:31 Comment(1)
The original poster is talking about a mono installation that is compiled from scratch, not downloaded via Xamarin, or through the mono installer.Summer
O
2

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.

Overnice answered 31/5, 2018 at 15:16 Comment(0)
E
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.).

Enzymolysis answered 30/12, 2014 at 22:0 Comment(1)
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.Margueritamarguerite
P
1

my project started compiling, when I removed lines

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

from it.

Pallaten answered 17/10, 2015 at 2:43 Comment(0)
H
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.

Histogen answered 24/2, 2018 at 14:15 Comment(1)
weird, but it worked ! Thanks!Moujik
H
0

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

Hope it works for you.

Hibbert answered 4/9, 2018 at 7:45 Comment(0)
W
0

I had the same problem.

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

Weatherboarding answered 1/10, 2021 at 7:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.