Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mono gtk hello world failing, 'Missing method'

Tags:

mono

gtk

gtk#

I am trying out mono for the first time. Here are the steps I took to set it up.

Installed Kubuntu 12.04 LTS in VirtualBox

apt-get install mono-complete gtk-sharp2

Then I tried running the hello world applications in this tutorial.

http://www.mono-project.com/Mono_Basics

The command line application ran fine.

I compiled the GTK application with the following command as per the instructions:

gmcs hello.cs -pkg:gtk-sharp-2.0

When I run the application it fails with the following errors:

Missing method System.Type::op_Inequality(Type,Type) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
  at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
  at Hello.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
  at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
  at Hello.Main () [0x00000] in <filename unknown>:0

To me it looks like the mono libraries are incompatible with the gtk-sharp libraries.

Does anyone have any suggestions on how I can get this working?

like image 473
copacetic Avatar asked May 06 '12 20:05

copacetic


1 Answers

All 12.04 Ubuntu editions have Mono defaulting to 4.0 profile (similar to .NET 4.0). You are compiling your hello.cs using gmcs compiler which is intended to target 2.0 profile (similar to .NET 2.0).

Use dmcs compiler instead of gmcs and the error will go away.

like image 124
Marek Safar Avatar answered Nov 06 '22 04:11

Marek Safar