无法引用SQLite.interop.dll

问题描述 投票:0回答:1

好吧,我知道这已经在这里问过几次了,但是这些建议都没有帮助。我下载了SQLite,进入垃圾箱并从那里获取了DLL。我正在尝试发布一个SQLite接口,当我编译运行时,这就是我得到的

我已经尝试通过VS 2015中的nuget管理器手动添加.DLL。两种方式都通过以下错误消息。

enter image description here

我不知所措。我不知道该怎么办。这是代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            string db = @"URI = file:C:\Users\Mason\Documents\test.db";

            try
            {
                var con = new SQLiteConnection(db);
                con.Open();
                var cmd = new SQLiteCommand(con);

                cmd.CommandText = "select * from test";
                cmd.ExecuteNonQuery();

                Console.Read();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.Read();
            }

        }
    }
}
c# database sqlite system.data.sqlite
1个回答
0
投票
好消息是...您不需要。

它只需要可供托管的SQLite程序集使用即可。

还是这样做吧...

将正确的SQLite.Interop.dll内部版本(x86,x64)复制到您的项目文件夹,并像在任何文件(图像,图标等)中一样在项目中

include将其复制到项目中。

然后,在其Properties中设置:

Build ActionContentCopy to Output DirectoryCopy Always

重建并享受!

© www.soinside.com 2019 - 2024. All rights reserved.