Mono TypeLoadException on XmlPreloadedResolver - c#

I'm working on porting a Windows console app over to Linux using Mono. On my dev machine (Ubuntu), the app works like a charm, but when I try it on my test machine (a vanilla Ubuntu 14.04 desktop install) I get the following error:
Unhandled Exception:
System.TypeLoadException: Could not load type 'System.Xml.Resolvers.XmlPreloadedResolver' from assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The only thing I've done to "prep" the test machine is run sudo apt-get install mono-complete and sudo apt-get upgrade. When I run dpkg --list | grep mono-system-xml on the test machine I see this:
$ dpkg --list | grep mono-system-xml
ii libmono-system-xml-linq4.0-cil 3.2.8+dfsg-4ubuntu1.1 all Mono System.Xml.Linq library (for CLI 4.0)
ii libmono-system-xml-serialization4.0-cil 3.2.8+dfsg-4ubuntu1.1 all Mono System.Xml.Serialization library (for CLI 4.0)
ii libmono-system-xml4.0-cil
whereas on my dev machine I see this:
$ dpkg --list | grep mono-system-xml
ii libmono-system-xml-linq4.0-cil 4.2.1.102-0xamarin1 all Mono System.Xml.Linq library (for CLI 4.0)
ii libmono-system-xml-serialization4.0-cil 4.2.1.102-0xamarin1 all Mono System.Xml.Serialization library (for CLI 4.0)
ii libmono-system-xml4.0-cil 4.2.1.102-0xamarin1 all Mono System.Xml library (for CLI 4.0)
I don't know for sure that that version mismatch is the root problem, but it's all I've got to go on for now. I tried installing monodevelop on the test machine via sudo apt-get install monodevelop, and I tried upgrading from the xamarin servers by running
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
to no avail. Is there a way to tell where that 4.2.1 version on my dev machine came from? And assuming that's the difference, why would this module be broken in the standard distribution? From the mono docs it's been implemented and stable for a long time...

So, it turned out this was basically just an order of operations problem.
I had installed mono-complete before adding the Xamarin feed, so I got the old broken 3.8 version of Mono that shipped with Ubuntu 14 instead of the latest and greatest. For whatever reason, adding the feed afterwards and doing an apt-get upgrade doesn't pick up the updated versions, so you either have to start clean and do things in the right order, or add the feed, look at the output from apt-cache showpkg mono-complete to determine the version you really want, and then specify it like sudo apt-get install mono-complete=4.2.2.30-0xamarin2.

Related

Mono-Dev ubuntu 17.04 "Debugger operation failed" [duplicate]

This question already has an answer here:
Console project fails to run in MonoDevelop 6.3 on Ubuntu
(1 answer)
Closed 5 years ago.
Hi everyone im trying to code in c# mono dev (version 6.3 build 863) using ubuntu 17.04
writing a simple "hello world" app
makes it crash saying
"
Debugger operation failed
Cannot start process because a file name has not been provided."
does anyone had the same problem or any ideas how to fix it?
I had the same problem with the same version 6.3 build 863 of MonoDevelop on Ubuntu 17.04.
If you don't need this specific build for some specific reason. I Can suggest you to install a previous version. In my experience I downgraded to 5.10 from repository as follow:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo... wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install monodevelop
install the dependency packages:
sudo apt-get install mono-devel

Raspberry PI with latest Mono

I would like to port some existing WinForms project into Raspberry PI but I'm having little success, mainly because it seems Mono's WinForms implementation has bugs in the TextBox widget.
After googling I found that this issue had actually been solved quite sometime ago, but the official version of MONO installed using apt-get is too old.
So I have tried numerous ways (which can be condensed into two) to upgrade my MONO to the latest version:
Add the Mono Project GPG signing key and the package repository to your system (http://www.mono-project.com/docs/getting-started/install/linux/). Result: The installation is failed, and render my Raspberry PI useless. Have to re-install the official Raspbian image again
Try to build the latest version of Mono myself (https://gist.github.com/tonemackay/21139ff56c1e124659fa). Result: The compilation failed because of some type conversion bug in the Mono sources.
For the two methods above, I have tried numerous ways to solve it myself, but with no success.
Hope someone can give a better suggestion.
-- Update 24th Dec 2016
The error message is as below. I have searched the web, it seems like I can only install / compile the latest MONO in PI 2 or 3 but not PI 1. :(
Processing triggers for ca-certificates ...
Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....Updating Mono key store
Illegal instruction
Done
done.
Errors were encountered while processing:
libglib2.0-cil
libgtk2.0-cil
libglade2.0-cil
libnunit-core-interfaces2.6.3-cil
libnunit-core2.6.3-cil
libnunit-util2.6.3-cil
libnunit-console-runner2.6.3-cil
libnunit-framework2.6.3-cil
libnunit-mocks2.6.3-cil
libnunit-cil-dev
libmono-cil-dev
libwebkit1.1-cil
mono-devel
monodoc-browser
mono-complete
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update && apt-get upgrade
sudo apt-get install mono-complete
If you have previous Mono version installed you need "apt-get dist-upgrade".

Unreal Engine 4 Setup problems

I am trying to run the Unreal Engine-4 setup on Ubuntu 14.04 but when running the command
sudo apt-get install build-essential mono-gmcs mono-xbuild mono-dmcs libmono-corlib4.0-cil libmono-system-data-datasetextensions4.0-cil libmono-system-web-extensions4.0-cil libmono-system-management4.0-cil libmono-system-xml-linq4.0-cil cmake dos2unix clang-3.5 libfreetype6-dev libgtk-3-dev libmono-microsoft-build-tasks-v4.0-4.0-cil xdg-user-dirs
I am running into an error saying
The following packages have unmet dependencies:
mono-gmcs : Depends: mono-mcs (= 3.12.1-0xamarin1) but 4.0.2.5-0xamarin1 is to be installed
E: Unable to correct problems, you have held broken packages.
Any clues on how to proceed?
but 4.0.2.5-0xamarin1 is to be installed
It appears you are using Mono 3.x install instructions for Unreal Engine-4's setup.
In Mono 4.x, the gmcs compiler (a shell script to docs/mcs) has been dropped as support for only 4.x+ frameworks are supplied by the default installer.
Remove the "mono-gmcs" from your apt-get install list, and try again. I am not sure if anything is in Unreal 4 is dependent on a Mono 3.x install or if Mono 4.x will work...
You can alway pin your Mono version to 3.12.1. Remove:
deb http://download.mono-project.com/repo/debian wheezy main
from "/etc/apt/sources.list.d/mono-xamarin.list" and add:
deb http://download.mono-project.com/repo/debian wheezy/snapshots/3.12.0 main"
deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main"
Then you can:
sudo apt-get update
After that, try your Unreal Engine-4 setup routine again and the Mono version will match the setup steps on Unreal's web site.

Need to run C# on linux server

I used to be able to run vb.net apps using just this
apt-get install mono-runtime
apt-get install mono-vbnc
But I now need at least 2.8.0 to run a certain app that has already been compiled on windows. I have the option between the following OS's
ubuntu-12.04-x86
ubuntu-12.04-x86_64
ubuntu-12.10-x86
ubuntu-12.10-x86_64
centos-5-x86
centos-5-x86_64
centos-5-elastix_2.0.1_amd64
centos-6-x86
centos-6-x86_64
debian-6.0-x86
debian-6.0-i386-minimal
debian-6.0-x86_64
debian-6.0-amd64-minimal
debian-7-x86
debian-7.0-x86_64
I've tried the following on multiple versions of ubuntu.
#!/bin/bash
echo Checking for prerequisites. Please enter password if prompted.
sudo apt-get update
sudo apt-get install libpng3 libpng3-dev libtool libtiff4 libtiff4-dev libexif12 libexif-dev libgif4 libgif-dev libpango1.0-dev libatk1.0-dev bison automake autoconf make gcc gtk-sharp2 build-essential xorg-dev libfreetype6 libfontconfig libfontconfig-dev gettext libglib2.0-dev git mono-complete libjpeg-dev
echo Downloading latest build of mono...
git clone git://github.com/mono/mono.git
echo Navigating to mono install directory.
cd mono
echo Building mono from source...
./autogen.sh --prefix=/usr/local
make
echo Installing mono, running with sudo
sudo make install
echo Done!
Checking the mono version says it has worked, but I cant actually run the app due to this error:
The assembly mscorlib.dll was not found or could not be loaded. It should have been installed in the 'usr/lib/mono/4.5/mscorlib.dll'.
Which OS should I use and how can I install mono 2.8.0 or later to run a C# app which has been compiled on windows?
Build a clean Linux OS from ISO, such as Ubuntu 12.04.
Install the stable Mono release on it, such as apt-get install mono-complete. This is required to bootstrap the later steps.
Install Git and check out Mono source code, and switch to a stable branch (such as mono-3.2.8-branch).
Build that version of Mono from source and install it.
I don't recommend 3.4.0 or 3.6.0 branch at this moment, as new commits are still added to them in the past week (June 17 today). 3.2.8 is also the Mono version bundled in Ubuntu 14.04.
What you have been wrong is to check out the master branch. No no, that's not a stable release you should use.

How to run .NET 4.5 on XSP using Mono?

I have installed Mono 3 however when I run xsp or xsp4 it shows that I'm using .NET 4.0. I need to have .NET 4.5. Is it possible? Where can I configure it?
I've seen this page but I don't have any of those folders where I downloaded sources.
This is what it shows when I enter website by running xsp4:
Version Information: 3.2.7 (master/1eef047 C nov 28 18:16:30 EET 2013); ASP.NET Version: 4.0.30319.17020
How I installed Mono and XSP
Firstly I downloaded Lubuntu 13.10 32bit and launched it inside VirtualBox. Then did apt-get update and apt-get upgrade. After that rebooted the system.
Make sure all commands are executed as super user.
sudo -s
Got dependencies
apt-get install autoconf automake libtool g++ gettext libglib2.0-dev libpng12-dev libfontconfig1-dev mono-gmcs git
Downloaded sources of Mono and XSP
cd /opt
git clone git://github.com/mono/mono.git
git clone git://github.com/mono/xsp.git
Installed latest stable Mono from github
cd /opt/mono
./autogen.sh --prefix=/usr
make
make install
Installed latest stable XSP from github
cd /opt/xsp
./autogen.sh --prefix=/usr
make
make install
Tested that I have 4.0 running on XSP instead of 4.5
cd /home/pc/web
xsp4 # 4.0
xsp2 # 2.0
xsp # 2.0
My configuration
/usr/bin/xsp4 looks like it should use 4.5. Just like this answer suggested. Also, I don't have xsp4.exe in my /usr/lib/mono/4.0/ only in /usr/lib/mono/4.5/ so I cannot copy anything like suggested in that answer.
#!/bin/sh
exec /usr/bin/mono $MONO_OPTIONS "/usr/lib/mono/4.5/xsp4.exe" "$#"
You say "I don't have any of those folders where I downloaded sources" referring to /opt/mono/bin/xsp4. But you're confusing things, and I know it because you shared how you installed mono.
/opt/mono should not be the place where you clone the mono repository to compile it. You should clone it somewhere else like your home folder. I.e.: /home/username/code/mono.
/opt/mono is where usually people install a custom version of mono. The way they do it is passing this path to the --prefix argument. But you're passing /usr as the prefix argument! So then you're installing it to a different location compared to the SO answer that you point out.
Also, it is not recommended that you do ALL those operations as a superuser. You normally compile code without root privileges, and you only need sudo for the install phase. So don't do "sudo -s" before everything. Just compile, and when you're done, do sudo make install. This will also make you have binaries that are not owned by root.

Categories

Resources