我有一个WPF应用程序运行VS2010 .Net3.5使用Nhibernate与FluentNHibernate + SQLite,一切正常.
现在我想改为使用.Net4,但这已经变成了一种比我想象的更痛苦的经历..在设置连接时我这样做:
var cfg = Fluently.Configure().
Database(SQLiteConfiguration.Standard.ShowSql().UsingFile("MyDb.db")).
Mappings(m => m.FluentMappings.AddFromAssemblyOf<MappingsPersistenceModel>());
_sessionFactory = cfg.BuildSessionFactory();
Run Code Online (Sandbox Code Playgroud)
BuildSessionFactory()调用抛出FluentConfigurationException:
创建SessionFactory时使用了无效或不完整的配置.检查PotentialReasons集合和InnerException以获取更多详细信息.
内部异常为我们提供了更多信息:
无法从NHibernate.Driver.SQLite20Driver,NHibernate,Version = 2.1.2.4000,Culture = neutral,PublicKeyToken = aa95f207798dfdb4创建驱动程序.
而且还有InnerException:
无法找到程序集System.Data.SQLite中的IDbCommand和IDbConnection实现.确保程序集System.Data.SQLite位于应用程序目录或全局程序集缓存中.如果程序集位于GAC中,请使用应用程序配置文件中的元素指定程序集的全名.
现在 - 对我来说听起来似乎没找到System.Data.SQLite.dll,但我无法理解这一点.引用的所有地方我都有"复制本地",我已经验证它是在使用SQLite的项目的每个构建文件夹中.我还手动将它复制到解决方案的每个Debug文件夹 - 没有运气.
笔记:
在@ devio的回答后,我尝试添加对SQLite dll的引用.这没有改变任何东西,但我希望我做对了..这是我添加到app.config文件的根节点的内容:
<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>
Run Code Online (Sandbox Code Playgroud)
有没有人使用Fluent成功使用.Net4和SQLite?救命!我迷路了...
使用ReSharper5转换为Visual Studio 2010后,我的一些单元测试开始失败.更具体地说,这适用于将NHibernate与SQLite一起使用的所有单元测试.这个问题似乎与SQLite有某种关系.不涉及NHibernate和SQLite的单元测试仍然正常运行.
例外情况如下:
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 <qualifyAssembly/> element
in the application configuration file to specify …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Microsoft.Jet.OLEDB驱动程序从我的C#应用程序连接到访问数据库.当我尝试打开连接时,出现错误:"'Microsoft.Jet.OLEDB.4.0'提供程序未在本地计算机上注册." 这是因为驱动程序仅在32位计算机上受支持.
我的解决方案是将引用它的项目的平台目标更改为x86.如果我尝试将所有项目更改为x86,我会遇到重大构建问题,所以我将它们全部留在"任何CPU"上
现在问题是当我在VS中启动时,它告诉我:"无法加载文件或程序集'MyProject,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一.尝试加载一个格式不正确的程序."
我已经尝试过我能想到的每一种配置,而我却无法让它发挥作用.有小费吗?