Bug 12838 - System.Core.dll should not be referenced automatically when targeting Mono / .NET 2.0
Summary: System.Core.dll should not be referenced automatically when targeting Mono / ...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: 4.0.5
Hardware: PC Linux
: --- normal
Target Milestone: master
Assignee: Lluis Sanchez
URL:
Depends on:
Blocks:
 
Reported: 2013-06-23 13:48 UTC by Michael Möller
Modified: 2013-06-25 11:32 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Small project demonstrating the problem. (1.38 KB, application/x-gzip)
2013-06-23 13:48 UTC, Michael Möller
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Michael Möller 2013-06-23 13:48:37 UTC
Created attachment 4181 [details]
Small project demonstrating the problem.

MonoDevelop automatically adds System.Core.dll as a reference when calling the compiler, even for projects with "Target framework" configured to "Mono / .NET 2.0". This reference is not listed in the project inside MonoDevelop, so it can't be removed manually. The command line looks something like this:

/usr/bin/mcs /noconfig "/r:/usr/lib/mono/2.0/mscorlib.dll" -nostdlib "/out:/home/michael/Test/Project/bin/Debug/Project.exe" "/r:/usr/lib/mono/2.0/System.dll" "/r:/usr/lib/mono/2.0/System.Core.dll" /nologo /warn:4 /debug:full /optimize- /codepage:utf8 /platform:x86 "/define:DEBUG"  /t:exe "/home/michael/Test/Project/Program.cs" 


In certain cases (for example when using a System.Linq reimplementation for .NET 2.0) this can lead to errors as for example this one:

"Error CS0121: The call is ambiguous between the following methods or properties: `System.Linq.Enumerable.Count<int>(this System.Collections.Generic.IEnumerable<int>)' and `System.Linq.Enumerable.Count<int>(this System.Collections.Generic.IEnumerable<int>)' (CS0121) (Project)"

Removing "/r:/usr/lib/mono/2.0/System.Core.dll" from the command and invoking the compiler directly from the command line allows the program to compile (and run) just fine.

As far as I know the System.Core.dll did not exist prior to .NET 3.5, so I am not sure why it can be referenced. And in any case the reference should not be forced by MonoDevelop.
Comment 1 Lluis Sanchez 2013-06-25 11:32:58 UTC
Fixed in master.