1

我使用 mspec 进行测试,并在测试中为我的数据库使用 SQLite x86 的 NHiernate 设置。问题是,当我使用 mspec r# runner 运行我的测试时,一切正常,但是从控制台运行它会出现一个错误,即它找不到 sqlite dll。

我的规范项目配置:

.net 4

x86(使用 x86 版本的 sqlite)

System.Data.SQLite,版本=1.0.64.0,Culture=neutral,PublicKeyToken=db937bc2d44ff139 mspec,版本=0.3.0.0,Culture=neutral,PublicKeyToken=null,目标运行时:v4.0.30319,目标:x86

MSpec 是从源代码构建的。在 Reflector 中,mspec.exe 显示为为 x86 构建的 - 这似乎适合我的设置,并且如上所述使用 r# runner 测试运行良好。

NHibernate.HibernateException:无法从 NHibernate.Driver.SQLite20Driver、NHibernate、版本=2.1.2.4000、Culture=neutral、PublicKeyToken=aa95f207798dfdb4 创建驱动程序。---> System.Reflection.TargetInvocationException:调用的目标已抛出异常。---> NHibernate.HibernateException:找不到程序集 System.Data.SQLite 中的 IDbCommand 和 IDbConnection 实现。确保程序集 System.Data.SQLite 位于应用程序目录或全局程序集缓存中。如果程序集在 GAC 中,请使用应用程序配置文件中的元素来指定程序集的全名。在 NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName) 在 NHibernate.Driver.SQLite20Driver..ctor()

有谁知道如何解决这个问题?

提前感谢多云维也纳的问候,

克里斯

4

1 回答 1

7

使用 fuslogvw.exe 我发现了错误(感谢提示;):“拒绝针对 v2.0.50727 构建的 IJW 模块,因为它可以在此过程中加载到另一个运行时。”

添加一个 mspec.exe.config 像:

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true" ></startup>
</configuration>

解决了这个问题,现在我的测试运行符合预期。

谢谢和问候,

克里斯

于 2010-09-27T08:05:11.300 回答