3

ここから次の例をdmcs(およびgmcs ...両方を試しました)でコンパイルしようとしています:

using System;
using System.Data;
using Mono.Data.Sqlite;

public class Example
{

    static void Main() 
    {
        string cs = "URI=file:test.db";

        using( SqliteConnection con = new SqliteConnection(cs))
        {

            con.Open();

            DataTable table = new DataTable("Friends2");

            DataColumn column;
            DataRow row;

            column = new DataColumn();
            column.DataType = System.Type.GetType("System.Int32");
            column.ColumnName = "Id";
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = Type.GetType("System.String");
            column.ColumnName = "Name";
            table.Columns.Add(column);

            row = table.NewRow();
            row["Id"] = 1;
            row["Name"] = "Jane";
            table.Rows.Add(row);

            row = table.NewRow();
            row["Id"] = 2;
            row["Name"] = "Lucy";
            table.Rows.Add(row);

            row = table.NewRow();
            row["Id"] = 3;
            row["Name"] = "Thomas";
            table.Rows.Add(row);

            string sql = "SELECT * FROM Friends2";

            using (SqliteDataAdapter da = new SqliteDataAdapter(sql, con))
            {
                using (new SqliteCommandBuilder(da))
                {
                    da.Fill(table);
                    da.Update(table);
                }
            }

            con.Close();
        }
    }
}

次の CL 引数を使用して、コンパイルを試みました。

dmcs sqlite8.cs -r:Mono.Data.Sqlite.dll, System.Data.dll
gmcs sqlite8.cs -r:Mono.Data.Sqlite.dll, System.Data.dll

そして、次のエラーが明らかになります。

sqlite8.cs(2,14): error CS0234: The type or namespace 'Data' does not exists in the namespace 'System'. Are you missing an assembly reference?

また

error CS2001: Source file 'System.Data.dll' could not be found
Compilation failed: 1 error(s), 0 warnings

そのため、Mono は System.Data 参照を見つけることができません。これを修正するにはどうすればよいですか? 私は C# に慣れていますが、CLI Mono コンパイルは初めてです。

4

1 に答える 1

5

-r1 つのオプションを使用して複数のアセンブリを渡すことはできません。次-rのように、参照ごとに指定する必要があります。

mcs sqlite8.cs -r:Mono.Data.Sqlite.dll -r:System.Data.dll

エラーに「ソース ファイル」が記載されていることに注意してください。

于 2013-05-22T16:38:27.247 に答える