views:

153

answers:

2

Mono works fine with my app, but when I try to compile a function like

int Yo(int a, int b = 1) {
     // blah...
}

It doesn't work, it says that "Default parameter specifiers are not permitted"

According to Mono's website

The Mono C# compiler is considered feature complete for C# 1.0, C# 2.0 and C# 3.0 (ECMA). A preview of C# 4.0 is distributed with Mono 2.6, and a complete C# 4.0 implementation is available with Mono 2.8 or when building Mono from our trunk source code release.

How can I successfully compile it?

+4  A: 

Make sure you have gotten Mono 2.8... It has not been released yet, so you will need to download the sources. The git archive page is here.

It is not ready yet, so you will need to get it from source and compile mono yourself before you can use C# 4.0 features and this is only provided that the mono team has in fact finished writing these features into their compiler.

Oded
Oh that's what I thought the problem was. Will it work fine with ASP.NET MVC 2 framework?
Alex
@Alex - The current mono should work with MVC 2 as is. The 2.8 branch is not ready yet - I wouldn't risk using it for a production app.
Oded
Ok thanks, I'll have to wait for Mono 2.8
Alex
+3  A: 

Our C# 4.0 compiler is available as the "dmcs" command as opposed to the "gmcs", "smcs" or "mcs" commands.

After Mono 2.8 we will work towards having a single command line compiler that will let you select the various profiles using a flag, but for now we created different scripts that act as frontends to the API profile/language level that you want to use

miguel.de.icaza
Wow didn't expect Miguel to answer my question :) Thank you. I really like Mono, and I wish you good luck. You are really making .NET cross platform.P.S. How can I ask MonoDevelop to use dmcs to compile my ASP.NET MVC project?
Alex
If you have a 4.0 runtime installed, you should be able to select target framework version in Project Options.
mhutch
Hm... I don't have this option though I have .NET 4 installed.Here's the screenshot:http://s51.radikal.ru/i134/1008/c5/2c9d0994e7af.jpg
Alex
That looks like a limitation in MonoDevelop's UI. Make sure you have the "dmcs" command available.
miguel.de.icaza
You know, I installed Ubuntu and MonoDevelop 2.4... And it worked! The weird thing is that I still had Runtime Version: Mono/.NET 3.5 but worked! Here's the screenshothttp://s52.radikal.ru/i137/1008/c9/906f62ac5bde.jpg the page displays "Welcome to ASP.NET MVC on Mono!2" (which is correct) but the IDE marked it as a syntax error. (???)Now I'll have to completely switch to Ubuntu :) (I wish you supported it officially, but badgerports also works)
Alex