Ello,

This is a quick public service announcement. Earlier today, ajmitch reminded me of a little gotcha that exists around Mono applications in Ubuntu 11.10. As a five second summary, in 11.10 the Debian Mono team switched the default runtime version from 2.0 to 4.0. This involved recompiling (and sometimes patching) all libraries and applications in the distribution with the new verison.

That's all well and good for programs you get from the repositories, but unfortunately that is not always the case. Sometimes you may receive an application precompiled or from a PPA that was originally compiled against the 2.0 profile. If you have an 11.10 system with its updated 4.0 libraries, that's not going to work. You'll get errors like

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

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Reflection.PropertyInfo.op_Inequality'.
  at Gtk.ListStore..ctor (System.Type[] types) [0x00000] in <filename unknown>:0 
  at Sysinfo.Sysinfo..ctor (System.String[] args) [0x00000] in <filename unknown>:0 
  at Sysinfo.Sysinfo.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Reflection.PropertyInfo.op_Inequality'.
  at Gtk.ListStore..ctor (System.Type[] types) [0x00000] in <filename unknown>:0 
  at Sysinfo.Sysinfo..ctor (System.String[] args) [0x00000] in <filename unknown>:0 
  at Sysinfo.Sysinfo.Main (System.String[] args) [0x00000] in <filename unknown>:0 

which is a classic indicator that Mono tried to run an application using the 2.0 profile using libraries compiled for 4.0. A quick workaround is to force the application to run using 4.0, like so

mono --runtime=v4.0 /usr/lib/myapp/myapp.exe

which will get the program running and is useful if you don't have the facility or the inclination to rebuild it.

(You can skip the rest if you're not a developer)

If you are able to recompile the program then you can do the above, but you can also rebuild the program against the 4.0 profile to fix the error properly. The most important thing for package maintainers to know is that (for Debian and Ubuntu only), you ought to be using the distribution's default compiler to build your software. This means that you should tell your build system to use /usr/bin/mono-csc. If you don't then you'll get whatever the upstream maintainer has used, which is likely to be gmcs, the 2.0 compiler. When you use mono-csc, you get the distribution's default compiler and if the default runtime is changed in the future then compatibility will be a no-change rebuild away.