Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mono mcs 'Winforms Hello World' gives compile error CS006: Metadata file 'cscompmgd.dll' could not be found

I'm new to linux and mono. I installed mono to a new Raspberry Pi machine using

sudo apt-get install mono-complete.  

I also did the update and upgrade using apt-get.

I then followed the helloWorld examples in the Mono Basics page in mono-project website: http://www.mono-project.com/docs/getting-started/mono-basics/

I managed to build and run the first 'Console Hello World' example using the following:

mcs hello.cs
mono hello.exe

However, when I tried the next example 'Winforms Hello World', I encountered the following error when running 'mcs hello.cs -pkg:dotnet':

error CS0006: Metadata file 'cscompmgd.dll' could not be found

However, it works if i use gmcs instead of mcs.

I googled here and there but no luck.

I can find a link to this file 'cscompmgd.dll' in '/usr/lib/mono/2.0' directory in my Raspberry Pi.

The installed mono version is 3.2.8 (returned by using 'mono --version').

Does anyone know why it works with gmcs but it doesn't work with mcs?

Thank you.

like image 438
brian Avatar asked Oct 09 '14 10:10

brian


2 Answers

Solved by adding the -lib: option like this:

mcs helloWinforms.cs -pkg:dotnet -lib:/usr/lib/mono/2.0
like image 170
brian Avatar answered Oct 13 '22 11:10

brian


Solution with adding

-lib:/usr/lib/mono/2.0

was not the best in my case (it broke a dependency on some 4.0 elements, specifically 'System.Threading').


Dirty, but works

Another, very dirty solution is to copy the

/usr/lib/mono/2.0/cscompmgd.dll

to your project folder (or wherever the Makefile is) and add

-r:cscompmgd.dll

when compiling (or add the filename after list of other included libraries specified by '-r'). There is probably a way to do that without copying the file, but that is beyond my capabilities.


So you end up with:

mcs helloWinforms.cs -pkg:dotnet -r:cscompmgd.dll
like image 35
mik13ST Avatar answered Oct 13 '22 12:10

mik13ST