【发布时间】:2011-11-05 08:38:58
【问题描述】:
我尝试将 NHibernate 与 SQLite 一起使用, 对于 .NET 4 和 32 位,版本 = 1.0.74.0。 我使用的是 64 位 WIN7,但在 x86 模式下构建应用程序 (VS2010 express 中默认)。
当我将相同的 SQLite 用作独立应用程序时,它可以正常工作,但是当
我尝试将它与 NHibernate 一起使用它会抛出 BadImageFormatExcepion
我调试了一下 NHibernate 并且在下面的语句中抛出了异常
System.Type.GetType("System.Data.SQLite.SQLiteConnection, System.Data.SQLite");
有人知道解决方案吗? 是因为我在 VS Express 中使用默认模式吗? 我是否需要使用其他方法指定平台? 尝试为 sqlite 下载其他一些 dll 吗?
我检查了一些其他的答案,所以我得到的最好的是 添加到我的 app.config 中:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
</DbProviderFactories>
</system.data>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
【问题讨论】:
标签: nhibernate sqlite x86 badimageformatexception typeloadexception