如何在mono下使用System.Data.SQLite?

发布于 2024-09-04 10:07:10 字数 870 浏览 1 评论 0原文

我下载了System.Data.SQLite,并尝试编译以下示例代码。

using System;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;

namespace test
{
  class Program
  {
    static void Main(string[] args)
    {
      SQLiteConnection.CreateFile("/Users/smcho/Desktop/SQLite-1/example/mydatabasefile.db3");
    }
  }
}

我运行了以下命令

mcs db.cs -r:System.Data.dll -r:System.Data.SQLite.dll

但是,我收到了如下错误消息。

** (/opt/local/lib/mono/1.0/mcs.exe:43249): WARNING **: The class System.Data.Common.DbConnection could not be loaded, used in System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
db.cs(12,7): error CS0103: The name `SQLiteConnection' does not exist in the current context
Compilation failed: 1 error(s), 0 warnings

可能出了什么问题?

I downloaded System.Data.SQLite, and tried to compile the following sample code.

using System;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;

namespace test
{
  class Program
  {
    static void Main(string[] args)
    {
      SQLiteConnection.CreateFile("/Users/smcho/Desktop/SQLite-1/example/mydatabasefile.db3");
    }
  }
}

I ran the following command

mcs db.cs -r:System.Data.dll -r:System.Data.SQLite.dll

But, I got the error messages as follows.

** (/opt/local/lib/mono/1.0/mcs.exe:43249): WARNING **: The class System.Data.Common.DbConnection could not be loaded, used in System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
db.cs(12,7): error CS0103: The name `SQLiteConnection' does not exist in the current context
Compilation failed: 1 error(s), 0 warnings

What might be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆沫 2024-09-11 10:07:10

使用 gmcs 而不是 mcs 解决了这个问题。

gmcs db.cs -r:System.Data.dll,System.Data.SQLite.dll

Using the gmcs instead of mcs solved this issue.

gmcs db.cs -r:System.Data.dll,System.Data.SQLite.dll
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文