Compiling System.Tuple in Mono

2019-07-23 09:06发布

问题:

I'm attempting to compile some C# with gmcs version 2.11.0 that includes System.Tuple. Supposedly it does exist in Mono (http://stackoverflow.com/questions/5346453/mono-is-there-a-system-tuple) and it is possible to compile using the flag:

gmcs -langversion:future

It doesn't seem to matter which langversion I use, the compiler always gives the same error:

error CS0234: The type or namespace name `Tuple' does not exist in the namespace `System'. Are you missing an assembly reference?

How can I compile C# code using Mono that uses System.Tuple?

回答1:

I believe the problem is that gmcs targets the Mono framework version equivalent to .NET 3.5. You could either try to persuade gmcs to target the Mono framework version equivalent to .NET 4, or you could use dmcs instead. (I couldn't get it to work even with gmcs -sdk:4 which I expected to work, so dmcs may be a better bet.)



标签: c# mono