Search code examples
c#winformsmono

Broken Mono C# code using System.Windows.Forms


A couple of months back I started a relatively simple C# app which I was compiling with Mono.

I try to resume work on this today, and despite having an executable proving it compiled fine before, it is now complaining about System.Windows.Forms

C:\Program Files\Mono-2.0.1\bin>mcs ../projects/test_1/test.cs
../projects/test_1/test.cs(2,14): error CS0234: The type or namespace name 'Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings

I found a forum post of someone with the same error, and this was recommended:

mcs Program.cs -r:System.Windows.Forms.dll -r:System.Drawing.dll -v2

However, the -v2 argument doesn't work, and without it there are just a series of other namespace errors (ToolStripButton and similar).

I have downloaded the latest Mono 2.2 but this still produces the same error.

How do I fix this?


Solution

  • gmcs Program.cs -r:System.Windows.Forms.dll -r:System.Drawing.dll
    

    gmcs uses the .NET 2.0 profile.