【问题标题】:compile cs files with mono?用单声道编译cs文件?
【发布时间】:2010-05-22 02:29:59
【问题描述】:

我正在尝试在 linux 上使用 mono 编译我的项目。我的 cmd 看起来像...

gmcs  Pages/UserProfile.cs   Properties/AssemblyInfo.cs   queues.cs   watch_editor.cs Class1.cs -define:USE_SQLITE -r:System -r:System.Collections -r:System.Collections.Generic -r:System.Collections.ObjectModel -r:System.Collections.Specialized -r:System.Configuration

但是很长。我得到了输出

error CS0006: cannot find metadata file `System.Collections'
error CS0006: cannot find metadata file `System.Collections.Generic'
error CS0006: cannot find metadata file `System.Collections.ObjectModel'
...

我该如何解决?

我也尝试了另一种方式(如下),并且在它们的末尾有相同的错误消息,带有 .dll

gmcs   -define:USE_SQLITE -r:System.dll -r:System.Collections.dll  -r:System.Web.UI.WebControls CommentCenter.cs   cookies.cs   db.cs   Default.aspx.cs 

【问题讨论】:

    标签: c# .net mono gmcs


    【解决方案1】:

    您混淆了程序集和命名空间。程序集(如 System.dll)是一个二进制库文件,可以包含多个命名空间中的类型。一个命名空间可以跨多个程序集拆分,程序集名称不必以任何方式与命名空间匹配。

    -r 用于引用程序集。您不需要引用命名空间。

    鉴于这些命名空间中的大多数类都在 mscorlib(默认引用)或 System.dll 中,您可能只是想要

    gmcs  Pages/UserProfile.cs   Properties/AssemblyInfo.cs   queues.cs   watch_editor.cs Class1.cs -define:USE_SQLITE -r:System
    

    我强烈建议您使用诸如 MonoDevelop 之类的 IDE。如果您有兴趣,可以查看它生成的编译器命令。

    【讨论】:

    • MonoDevelop 的 ATM 不工作。显然其他人遇到了麻烦,没有简单的解决方案(似乎)
    • 也许你最好也问一个关于这个问题的问题?
    猜你喜欢
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多