Beginner: C# Winform in Linux using Mono

H

Hitchkas

I have a very beginner and fundamental question regarding porting and
running C# programs in Linux. As a background I am a total idiot when
it comes to Linux but somehow managed to install Ubuntu 7.04 Feisty
Fawn and Monodevelop 0.12 on a machine. So far so good, however I
cannot compile and run a simplest winform application. Basically,
"System.Windows.Forms" is not recognized and cannot even do a
MessageBox.Show.

So, my basic question is what I have to do to be able to compile and
run the following simple Winform application on Ubuntu 7.04 with
momodevelp 0.12? Apparently "System.Windows.Forms" is missing and
cannot get and install it. Any help or pointer is highly appreciated.

------------ sample program from mono site ------------------
using System;
using System.Drawing;
using System.Windows.Forms;

public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}

public HelloWorld ()
{
Button b = new Button ();
b.Text = "Click Me!";
b.Click += new EventHandler (Button_Click);
Controls.Add (b);
}

private void Button_Click (object sender, EventArgs e)
{
MessageBox.Show ("Button Clicked!");
}
}
 
P

Peter Bradley

Ysgrifennodd Hitchkas:
So, my basic question is what I have to do to be able to compile and
run the following simple Winform application on Ubuntu 7.04 with
momodevelp 0.12? Apparently "System.Windows.Forms" is missing and
cannot get and install it. Any help or pointer is highly appreciated.

------------ sample program from mono site ------------------
using System;
using System.Drawing;
using System.Windows.Forms;

Do you get any errors when you compile? If so, what error message do
you get? Have you included System.Windows.Forms in your project references?

You might also think about posting to the Mono list:

(e-mail address removed)

HTH


Peter
 
T

Tom Spink

Hitchkas said:
I have a very beginner and fundamental question regarding porting and
running C# programs in Linux. As a background I am a total idiot when
it comes to Linux but somehow managed to install Ubuntu 7.04 Feisty
Fawn and Monodevelop 0.12 on a machine. So far so good, however I
cannot compile and run a simplest winform application. Basically,
"System.Windows.Forms" is not recognized and cannot even do a
MessageBox.Show.

So, my basic question is what I have to do to be able to compile and
run the following simple Winform application on Ubuntu 7.04 with
momodevelp 0.12? Apparently "System.Windows.Forms" is missing and
cannot get and install it. Any help or pointer is highly appreciated.

------------ sample program from mono site ------------------
using System;
using System.Drawing;
using System.Windows.Forms;

public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}

public HelloWorld ()
{
Button b = new Button ();
b.Text = "Click Me!";
b.Click += new EventHandler (Button_Click);
Controls.Add (b);
}

private void Button_Click (object sender, EventArgs e)
{
MessageBox.Show ("Button Clicked!");
}
}

Hi,

I'm not sure what the Ubuntu package names are (I'm running Debian), but you
may need to install the appropriate '-cil' versions of the libraries. In
Debian, the package name for winforms is 'libmono-winforms1.0-cil'
and 'libmono-winforms2.0=cil'.

After ensuring you have these packages installed, you need to make sure
you're compiling with a reference to those libraries, so, using the
command-line:

gmcs -r:System.Windows.Forms.dll <source-files>

And, in MonoDevelop, you need to add references to the appropriate
libraries.
 
H

Hitchkas

Ysgrifennodd Hitchkas:





Do you get any errors when you compile? If so, what error message do
you get? Have you included System.Windows.Forms in your project references?

You might also think about posting to the Mono list:

(e-mail address removed)

HTH

Peter

The error is that dotnet library/package is not available. Thanks for
your help and for the pointer to the Mono list. I will post there.
 
H

Hitchkas

Hi,

I'm not sure what the Ubuntu package names are (I'm running Debian), but you
may need to install the appropriate '-cil' versions of the libraries. In
Debian, the package name for winforms is 'libmono-winforms1.0-cil'
and 'libmono-winforms2.0=cil'.

After ensuring you have these packages installed, you need to make sure
you're compiling with a reference to those libraries, so, using the
command-line:

gmcs -r:System.Windows.Forms.dll <source-files>

And, in MonoDevelop, you need to add references to the appropriate
libraries.

--
Tom Spink
University of Edinburgh- Hide quoted text -

- Show quoted text -

Thank you very much. That was it. I also upgraded to monodevelop
0.14 and it works now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top