我需要帮助。我使用nuget将最新版本的“ System.Data.SQLite”安装到我的库项目中,一切正常!但是,当我启动我的项目时,它出现了一个异常,我调用了我的库代码,说:
异常类型:“ BadImageFormatException” 异常消息:无法加载文件或程序集System.Datas.SQLite,Version = 1.0.110.0,Culture = neutral,PublicTokenKey = db237bc2d44ff139或其依赖项之一。该模块应该包含一个程序集清单
请需要帮助。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SQLite;
using SchoolManager.Datas.Entity;
using SchoolManager.Datas.Attributes;
namespace SchoolManager.Datas.Context
{
public abstract class BaseContext
{
private SQLiteConnectionStringBuilder connectionString;
public BaseContext(string database = "")
{
connectionString = new SQLiteConnectionStringBuilder();
//connectionString.Server = server;
connectionString.DataSource = @"D:\Projects\Visual C#\School Manager\SchoolManagerServer\Datas\db_schoolmanager.db";
connectionString.DefaultTimeout = 5000;
connectionString.SyncMode = SynchronizationModes.Off;
connectionString.JournalMode = SQLiteJournalModeEnum.Memory;
connectionString.PageSize = 65536;
connectionString.CacheSize = 16777216;
connectionString.FailIfMissing = false;
connectionString.ReadOnly = false;
}
public void TestConnection()
{
try
{
SQLiteConnection conn = new SQLiteConnection(connectionString.ToString());
conn.Open();
Console.WriteLine("Connected !");
conn.Close();
Console.WriteLine("Closed !");
}
catch (SQLiteException e)
{
Console.WriteLine("Error : " + e.Message);
}
}
public class SMDBContext : BaseContext
{
public SMDBContext() : base("db_schoolmanager.db")
{
}
}
}
而且我还在Visual Studio 2015 Entreprise中看到了此警告:
警告正在构建的项目“ MSIL”的处理器体系结构与引用“ D:\ Projects \ Visual C#\ School Manager \ SchoolManagerDatas \ bin \ Debug \ SchoolManager.Datas.dll”的处理器体系结构之间不匹配”,“ AMD64”。这种不匹配可能会导致运行时失败。请考虑通过Configuration Manager更改项目的目标处理器体系结构,以使项目和引用之间的处理器体系结构保持一致,或者依赖于具有与项目目标处理器体系结构相匹配的处理器体系结构的引用。 SchoolManagerClient
SchoolManager.Datas.dll是我的图书馆项目,而SchoolManagerClient是使用该图书馆执行CRUD的项目