I have some C# code using Tuple
s:
public class Test {
static void Main() {
Tuple<int, int> t = Tuple.Create(0, 1);
}
}
I tried compiling using
mcs -debug+ -o Test.exe Test.cs
but it gives the error
Test.cs(3,9): error CS0246: The type or namespace name `Tuple' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 1 error(s), 0 warnings
I thought it might be trying to compile against an old version of mscorlib which lacks tuples. Looking at the man page, it seems you specify the version using -sdk:4
, but that doesn't work either:
$ mcs -sdk:4 Test.cs
Unhandled Exception: System.TypeLoadException: Type 'System.Dynamic.BinaryOperationBinder' not found in assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
(followed by a stack trace).
I am running:
$ mcs --version
Mono C# compiler version 2.10.8.1
on Ubuntu Precise. According to the documentation, Mono has supported .NET 4.0 since version 2.8, and in particular supports System.Tuple
, so that shouldn't be the issue.
How do you compile code that uses Tuple
s?