mono gtk hello world failing, 'Missing method' - mono

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?

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.

Related

Error when trying to run steambot on vps debian System.MissingMethodException: Method not found: 'System.Array.Empty'

I have built the solution using monodevelop on windows, then transferred the files to my vps using Filezilla. It works fine on windows. But when i try to run steambot using mono steambot.exe i get the errors:
Unhandled Exception: System.MissingMethodException: Method not found: 'System.Array.Empty'.
at SteamBot.Program.BotManagerMode () [0x00000] in <filename unknown>:0
at SteamBot.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Array.Empty'.
at SteamBot.Program.BotManagerMode () [0x00000] in <filename unknown>:0
at SteamBot.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
mattimat#mattimat-ubuntu:~/steambot/SteamBot-master/Bin/Release$ mono SteamBot.exe
Missing method System.Array::Empty<[1]>() in assembly /usr/lib/mono/4.0/mscorlib.dll, referenced in assembly /home/mattimat/steambot/SteamBot-master/Bin/Release/SteamBot.exe
Unhandled Exception: System.MissingMethodException: Method not found: 'System.Array.Empty'.
at SteamBot.Program.BotManagerMode () [0x00000] in <filename unknown>:0
at SteamBot.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Array.Empty'.
at SteamBot.Program.BotManagerMode () [0x00000] in <filename unknown>:0
at SteamBot.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
mattimat#mattimat-ubuntu:~/steambot/SteamBot-master/Bin/Release$
Mono version:
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-8+deb7u1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
Again, works fine on windows. VPS is Debian 7.11 x32
public static T[] System.Array.Empty<T>() was added in .Net 4.6 and thus your older version of Mono would be running .Net 4.5 and the error would be expected.
Either update your version of Mono to 4.8+ or removed the usage of Array.Empty and compile against the .Net 4.5 framework.
re: https://msdn.microsoft.com/en-us/library/dn906179(v=vs.110).aspx

ASP.NET vNext on Linux Ubuntu 14.04. Unable to load Kestrel

I've installed mono 3.8.0, installed kvm and ran the kp=vm upgrade and
My K runtime version is as follows
Active Version Runtime Location Alias
1.0.0-beta3 mono ~/.k/runtimes default
After running the kpm restore from the folder containing the project.json file
I get an error while running the k kestrel command.
I guess the following error has to do with the libuv installation, which I also have installed - version 1.4.2, or at least I think so. Has anyone come across this error ?
System.InvalidOperationException: Unable to load application or execute command 'Microsoft.AspNet.Hosting'. Available commands: web, kestrel. at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundException (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.Exception innerException) [0x00000] in <filename unknown>:0 at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in <filename unknown>:0 at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
Turns out that the problem was pretty simple. Although I had the kestrel command defined in the project.json file, I did not include the "Kestrel" dependency in the dependencies section.
Once I added that it worked.
For beta3, you need mono 3.12..

using p4net.api in Mono

Anyone managed to get the Perforce p4api.net work with Linux ?
My projects build correctly on Mono 2.8.4, the dlls (p4bridge.dll and p4api.net.dll are in bin/Debug, but whenever I try to execute it, I get this exception :
Unhandled Exception: System.DllNotFoundException: p4bridge.dll
at (wrapper managed-to-native) Perforce.P4.P4Bridge:ConnectA (string,string,string,string,Perforce.P4.P4CallBacks/LogMessageDelegate)
at Perforce.P4.P4Server..ctor (System.String server, System.String user, System.String pass, System.String ws_client) [0x00000] in <filename unknown>:0
at Perforce.P4.Connection.Connect (Perforce.P4.Options options) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: p4bridge.dll
at (wrapper managed-to-native) Perforce.P4.P4Bridge:ConnectA (string,string,string,string,Perforce.P4.P4CallBacks/LogMessageDelegate)
at Perforce.P4.P4Server..ctor (System.String server, System.String user, System.String pass, System.String ws_client) [0x00000] in <filename unknown>:0
at Perforce.P4.Connection.Connect (Perforce.P4.Options options) [0x00000] in <filename unknown>:0
The API is the latest (2013.3) with MonoDevelop 2.8.4 as mentionned, and all mono RPMs are up to date.
Again, as mentionned, both Perforce DLLs are copied into bin/Debug, the project compiles properly, and it does find the p4api.net.dll (as the exception shows), but not the p4bridge.dll. I'm starting to suspect that p4bridge.dll is not a managed .NET library.
Any ideas ?
--JFG
p4bridge is not a managed library so you would need to build it for each platform that you want to run on.
If you want to use P4NET.API in Mono, you could take a look at the P4Connect source code. That project includes a version of the P4NET.API library which works in OSX under Mono. They have yet to integrate that code back into the main P4NET.API library though.

Not able to open MonoDevelop v 2.4.2

When I try to open MonoDevelop this error appears in the console log
com.apple.launchd.peruser.501[249] ([0x0-0x13013].com.ximian.monodevelop[308]) Exited with exit code: 255
How can I fix the problem?
EDIT: Snow Leopard 10.6.8, MonoDevelop 2.4.2 and Mono 2.10.5.
UPDATE: This is the error if I try to run MonoDevelop from shell
LSOpenURLsWithRole() failed with error -10810 for the file /Applications/MonoDevelop.app.
UPDATE 2: I've found the crash reporter for mono
FATAL ERROR [2011-09-03 15:06:25Z]: MonoDevelop failed to start. Some of the assemblies required to run MonoDevelop (for example gtk-sharp, gnome-sharp or gtkhtml-sharp) may not be properly installed in the GAC.
System.DllNotFoundException: /Library/Frameworks/Mono.framework/Versions/2.10.5/lib/libgtk-quartz-2.0.0.dylib
at (wrapper managed-to-native) Gtk.Application:gtk_init (int&,intptr&)
at Gtk.Application.do_init (System.String progname, System.String[]& args, Boolean check) [0x00000] in <filename unknown>:0
at Gtk.Application.Init (System.String progname, System.String[]& args) [0x00000] in <filename unknown>:0
at MonoDevelop.Ide.IdeStartup.Run (System.String[] args) [0x00000] in <filename unknown>:0
at MonoDevelop.Startup.MonoDevelopMain.Main (System.String[] args) [0x00000] in <filename unknown>:0
Any help?
For those interested in:
Uninstall Mono with this script uninstall script. You have to save the script in a file with extension .sh
Save the file in the desktop as uninstallMonoFr.sh (for example)
Open a terminal window: cd Desktop, sudo ./uninstallMonoFr.sh, insert your pwd
Download mono framework 2.10.4 (this version works for me)
Install again
I don't know if the problem is due to 2.10.5 version of mono framework. 2.10.4 works well.
UPDATE Seems that Mono 2.10.5 still presenting a package bug. MonoDevelop can't open with this version. Mono 2.10.4 works.
UPDATE 2 I've just installed 2.10.6 and it works. MonoDevelop now opens correctly.
This also helped me (permission issue):
http://answers.unity3d.com/questions/277759/cannot-start-built-in-monodevelop.html
I just added myself (user) with read&write permissions.

NAnt build issues with Mono

I am trying to build a Mono project using NAnt but I get the error listed below. I have tried altering the environment variable PKG_CONFIG_PATH to include the path leading to the file: mono.pc but that does not seem to work.
Failed to initialize the 'Mono 3.5 Profile' (mono-3.5) target framework.:
NAnt.Core.BuildException: Failed to initialize the 'Mono 3.5 Profile' (mono-3.5) target framework. ---> Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/.:
NAnt.Core.BuildException: Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/.
at NAnt.Core.Tasks.FailTask.ExecuteTask () [0x00000] in <filename unknown>:0
at NAnt.Core.Task.Execute () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at NAnt.Core.FrameworkInfo.Init () [0x00000] in <filename unknown>:0
at NAnt.Core.FrameworkInfo.Validate () [0x00000] in <filename unknown>:0
at NAnt.Core.ProjectSettingsLoader.ConfigureRuntimeFramework () [0x00000] in <filename unknown>:0
I've recently had the same problem trying to install the TAO Framework on Mac OSX 10.6.5 under Mono 2.8.1 with Nant 0.90 (FYI). Here's how I was led to solve this (guided by this page):
Locate the nant script itself ('/usr/bin/nant' on OSX, try 'which nant')
Open the 'nant' script in an editor (you might need the right permissions).
On a new line and before the 'exec ...' line, add something like:
export
PKG_CONFIG_PATH=/path/to/Mono/Framework/Versions/VERSION/lib/pkgconfig
my Mac OSX version looks like:
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/
(nb. my version actually has 2 pkgconfig paths, separated by a colon ':', '/usr/lib/pkgconfig' is also searched automatically, JFYI).
Also, you should add the exact same 'export' line to one of your .bashrc or .profile files (or the corresponding /etc/bashrc or /etc/profile files to set this globally).
Hope this helps.
Cheers
Rich
For me adding '/Library/Frameworks/Mono.framework/Versions/Current/bin' to the PATH has solved the issue on Mac OS X 10.7.3 with Mono 2.10.9 and NAnt 0.91.