简体   繁体   English

mono mcs'Winforms Hello World'给出编译错误CS006:找不到元数据文件'cscompmgd.dll'

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

I'm new to linux and mono. 我是linux和mono的新手。 I installed mono to a new Raspberry Pi machine using 我使用单声道安装到新的Raspberry Pi机器上

sudo apt-get install mono-complete.  

I also did the update and upgrade using apt-get. 我还使用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/ 然后我在单项目网站的Mono Basics页面中关注了helloWorld示例: 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: 我设法使用以下内容构建并运行第一个“Console Hello World”示例:

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': 但是,当我尝试下一个示例'Winforms Hello World'时,运行'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. 但是,如果我使用gmcs而不是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. 我可以在我的Raspberry Pi的'/usr/lib/mono/2.0'目录中找到这个文件'cscompmgd.dll'的链接。

The installed mono version is 3.2.8 (returned by using 'mono --version'). 安装的单声道版本是3.2.8(使用'mono --version'返回)。

Does anyone know why it works with gmcs but it doesn't work with mcs? 有谁知道为什么它适用于gmcs但它不适用于mcs?

Thank you. 谢谢。

通过添加-lib:选项解决此问题:

mcs helloWinforms.cs -pkg:dotnet -lib:/usr/lib/mono/2.0

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'). 在我的情况下不是最好的(它破坏了对4.0元素的依赖,特别是'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 到您的项目文件夹(或Makefile所在的位置)并添加

-r:cscompmgd.dll

when compiling (or add the filename after list of other included libraries specified by '-r'). 编译时(或在'-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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM