开发者

Could not create the driver from NHibernate.Driver.SQLite20Driver

Here's the code that raises the exception

开发者_如何转开发   public Configuration GetConfiguration()
    {
        var persister = SQLiteConfiguration
            .Standard
            .UsingFile("Test.db")
            .ShowSql();


        var configuration = Fluently
            .Configure()
            .Database(persister)
            .Mappings(map => map.FluentMappings.AddFromAssemblyOf<WordMap>())
            .BuildConfiguration();

        new SchemaExport(configuration).Execute(true, true, false);

        return configuration;

    }

The full exception text:

Failure: NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.

----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.

----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly.

Version of NHibernate is 2.1.2.4000

Version of System.Data.SQLite is 1.0.66.0

Target Framework is 3.5 (x86)

Local copy for System.Data.SQLite is ON.

What may be wrong?


Just copy System.Data.SQLite.dll library to the the base directory of your application (especially where NHibernate.dll library is placed). You even don't need it to add as reference under VS.

Regards
Bronek


I just installed the SQLite NuGet package and that worked for me.


I got rid of this issue by adding useLegacyV2RuntimeActivationPolicy="true" to app.config. See Problem Upgrading NHibernate SQLite Application to .Net 4.0


Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4

Solution:

testsettings: choose hosts choose run tests in 64 bit process on 64 bit machine

hoping I could help.

merry coding


If LocalCopy is on, is it on for a version of System.Data.SQLite in the start-up project because that's where it'll be looking for it, not in the bin directory of a sub-project.


In VS 2019, in Test -> Processor Architecture for AnyCPU Projects, I changed from x64 to Auto and it solved my problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜