A bit about the stuff I've done


Showing posts with label mono. Show all posts
Showing posts with label mono. Show all posts

Friday, 17 August 2012

Solving "Could not load file or assembly" problems on mono

So once again I have been tearing my hair out for hours trying to solve this problem.
Specifically in my case it was mod-mono-server2.exe that was producing this error. Now I *know* that that file exists - I checked, in fact that was the assembly I was executing.
So it must be one of the dependencies - but which one?
It turns out there IS a way to find out.
By setting 2 environment variables before attempting to run the application you can get some debugging information which tells you exactly what files mono was trying to find when it errored.

The 2 variables in question are:
MONO_LOG_LEVEL=info MONO_LOG_MASK=asm
So if you run
MONO_LOG_LEVEL=info MONO_LOG_MASK=asm mono myapp.exe
You will get a stack load of debugging info on the console, and just before the exception you should see some lines which looks something similar to this:
Mono-INFO: Assembly Loader probing location: '/usr/lib64/mono/gac/mod-mono-server2/2.10.0.0__0738eb9f132ed756/mod-mono-server2.dll'. Mono-INFO: Assembly Loader probing location: '/usr/lib64/mod-mono-server2.dll'. Mono-INFO: Assembly Loader probing location: '/usr/lib64/mono/gac/mod-mono-server2/2.10.0.0__0738eb9f132ed756/mod-mono-server2.exe'. Mono-INFO: Assembly Loader probing location: '/usr/lib64/mod-mono-server2.exe'. Handling exception type FileNotFoundException
Bingo! It's looking for an assembly called "mod-mono-server2"
But wait a minute! That's the assembly I'm running!

And no - I have no idea why it can't find it when I've actually given it the path to look in!
But since I can see where it is looking a quick symbolic link solves my issue:

ln -s "/usr/local/lib/mono/2.0/mod-mono-server2.exe" /usr/lib64/
This is probably a bad idea, there must be a good reason why it can't find it in the correct location.

Now I'm getting a different error about non-blocking sockets.

*sigh*

Thursday, 16 August 2012

Installing MONO on CENTOS

I've spent literally hours tearing my hair out trying to get this sorted so I thought I would share what I have found here:

Most of the search results on google are out of date and/or contain links which no longer work.

I also tried compiling everything from source but ran into trouble here too.

Eventually after much headscratching I found a solution :)

Take a look at this page: http://fedoraproject.org/wiki/EPEL

Ignore that this is a fedora project as it works just fine on centos.

Part way down the page under the "How can I use these extra packages?" heading are a couple of links. Choose the one that is appropriate to your version of centos. e.g. I am using centos 6 so I used the "newest version of 'epel-release' for EL6" link.

Download the rpm file and install it.
You should probably verify the rpm before installing, but I couldn't work out how and I was loosing patience by this point!

rpm -i epel-release-*.noarch.rpm
Now you should be able to search for and install the mono packages (and others) using yum.

e.g.
yum install mono-core mono-data mono-devel mono-extras mono-web mono-winforms monodoc mono-web-devel
N.B. there is no monodevelop included in this lot.
And I can't find anywhere to get it either :(