使用FluentNHibernate +的SQLite与.NET4问题? [英] Problems using FluentNHibernate + SQLite with .NET4?

查看:203
本文介绍了使用FluentNHibernate +的SQLite与.NET4问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有运行与使用NHibernate与FluentNHibernate + SQLite的VS2010 .NET3.5 WPF应用程序,和一切工作正常。

I have a WPF application running with VS2010 .Net3.5 using Nhibernate with FluentNHibernate + SQLite, and all works fine.

现在我想改变使用.NET4,但这已经变成了更为痛苦的经历,然后我的预期。当设置了我这样做的连接:

Now I want to change to use .Net4, but this has turned into a more painful experience then I expected.. When setting up the connection I do this:

var cfg = Fluently.Configure().
    Database(SQLiteConfiguration.Standard.ShowSql().UsingFile("MyDb.db")).
    Mappings(m => m.FluentMappings.AddFromAssemblyOf<MappingsPersistenceModel>());
_sessionFactory = cfg.BuildSessionFactory();                    

在BuildSessionFactory()调用抛出一个FluentConfigurationException说:

The BuildSessionFactory() call throws a FluentConfigurationException saying:

在创建一个SessionFactory无效或不完整的配置使用。检查PotentialReasons收集和的InnerException了解更多信息。

An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more details.

内部异常给了我们更多的信息:

The inner exception gives us more information:

无法创建NHibernate.Driver.SQLite20Driver,NHibernate的,版本= 2.1.2.4000,文化=司机中性公钥= aa95f207798dfdb4。

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

和更多的InnerException:

And further InnerException:

在装配System.Data.SQLite的IDbCommand和的IDbConnection实施找不到。确保大会System.Data.SQLite位于应用程序目录中或在全局程序集缓存。如果程序集是在GAC中,使用元素的应用程序配置文件中指定程序集的全名。

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.

现在 - 对我来说,它听起来就像没有找到 System.Data.SQLite.dll ,但我不明白这一点。这个到处引用我有复制本地,而我已经验证这是在每一个build文件夹中使用SQLite的项目。我也手动复制到解决方案的每个Debug文件夹 - 没有运气

Now - to me it sounds like it doesn't find System.Data.SQLite.dll, but I can't understand this. Everywhere this is referenced I have "Copy Local", and I have verified that it is in every build folder for projects using SQLite. I have also copied it manually to every Debug folder of the solution - without luck.

注:

  • 在这之前,我升级到.NET4的工作就好了完全相同的code。
  • 在我没有看到前面的一些64位的x86不匹配的问题,但我已经转向使用86作为目标平台,并为所有引用的DLL。我已经验证,在Debug文件夹中的所有文件都是86。
  • 我已经试过了precompiled流利的DLL,我曾尝试编制自己,我已编制使用.NET4我自己的版本流利的。
  • 在我看到有别人也已经看到了这个问题,,但我真的没有看到任何解决办法呢。
  • This is exactly the same code that worked just fine before I upgraded to .Net4.
  • I did see some x64 x86 mismatch problems earlier, but I have switched to use x86 as the target platform and for all referenced dlls. I have verified that all files in the Debug-folder are x86.
  • I have tried the precompiled Fluent dlls, I have tried compiling myself, and I have compiled my own version of Fluent using .Net4.
  • I see that there are also others that have seen this problem, but I haven't really seen any solution yet.

在@ devio的答案,我尝试添加一个参考SQLite的DLL。这并没有改变什么,但我希望我做是正确的,但..这是我添加到app.config文件的根节点:

After @devio's answer I tried adding a reference to the SQLite dll. This didn't change anything, but I hope I made it right though.. This is what I added to the root node of the app.config file:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <qualifyAssembly partialName="System.Data.SQLite" fullName="System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
    </assemblyBinding>
</runtime>

任何人在那里用流利的用.NET4和SQLite成功?帮帮我!我迷路了......

Anyone out there using Fluent with .Net4 and SQLite successfully? Help! I'm lost...

推荐答案

检查您的System.Data这参考的版本。这听起来好像System.Data.SqlLite找不到IDbCommand的与我怀疑是版本2.0.0.0版本和的IDbConnection它建成。我猜想,现在你已经升级到.NET 4要引用System.Data这版本4.0.0.0。

Check the version of your System.Data reference. It sounds to me like System.Data.SqlLite can't find the version of IDbCommand and IDbConnection that it was built with which I suspect is version 2.0.0.0. I suspect that now you've upgraded to .Net 4 you are referencing System.Data version 4.0.0.0.

如果这是你应该能够添加一个绑定重定向到解决问题的情况下:

If this is the case you should be able to add a binding redirect to resolve the problem:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
        <assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089"/>
        <bindingRedirect oldVersion="2.0.0.0" newVersion="4.0.0.0"/>
    </dependentAssembly>
</assemblyBinding>

这篇关于使用FluentNHibernate +的SQLite与.NET4问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆