升级到 VS2010 和 Re#5 后 SQLite 相关的 nUnit 测试出现问题
使用 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 the full name of the assembly.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
异常是清理未成功创建的NHibernate对象时TearDown上的NullReferenceException,但问题似乎与SQLite有关。
我通过 ReSharper 运行单元测试,但是当直接通过 NUnit.exe 应用程序运行它们时,我遇到了相同的异常。但是,通过 x86 变体 (NUnit-x86.exe) 运行它们,所有测试都运行良好。它可能与 64 位和 32 位 dll 的混合有关吗?通过VS2008 + ReSharper4.5仍然运行良好。
请注意,我的项目的目标框架仍然是.NET3.5。
有人以前见过这个问题吗?
After converting to Visual Studio 2010 with ReSharper5 some of my unit tests started failing. More specifically this applies to all unit tests that use NHibernate with SQLite. The problem seem to be related to SQLite somehow. The unit tests that does not involve NHibernate and SQLite are still running fine.
The exception is as follows:
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 the full name of the assembly.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
The exception is the NullReferenceException on TearDown when cleaning up NHibernate objects that wasn't successfully created, but the problem seem to be related to SQLite somehow.
I run my unit tests through ReSharper, but I get the same exception when running them directly through the NUnit.exe application. However, running them through the x86 variant (NUnit-x86.exe) all tests run fine. Can it be related to some mixing of 64bit and 32bit dlls? It still runs fine through VS2008 + ReSharper4.5.
Note that the target framework of my projects still is .NET3.5.
Anyone seen this problem before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
64 位和 32 位 dll 之间似乎存在某种混淆。切换到使用 SQLite.dll 的 x64 变体可以解决该问题。我不确定为什么 VS2008 没有给出这个问题。
There seems to be a mixup between 64bit and 32bit dlls somehow. Switching to use the x64 variant of SQLite.dll fixes the problem. I'm not sure why VS2008 doesn't give this problem though.
我遇到了同样的错误,我确信这是由于.NET 4.0和VS 2010造成的,但是当我在工作中升级到Resharper 5(在VS 2008上)时,我得到了同样的错误。
我认为这是由 Resharper 5 测试运行程序引起的。当我使用 TestDriven.NET 时,它们都运行成功。
我希望 JetBrains 能够尽快发布修复程序。根据我在论坛上看到的情况,他们已经意识到了这个问题,所以修复应该不会花太长时间。
虽然此问题已修复,但我将使用 TestDriven.NET 来运行我的测试。但我会怀念出色的 Resharper UI ;)
I got the same error, I was sure that it was due to .NET 4.0 and VS 2010, but when I upgraded to Resharper 5 at work (on VS 2008), I got the same error.
I think this is caused by Resharper 5 test runner. When I used TestDriven.NET they all ran successfully.
I hope JetBrains will release a fix soon. According to what I saw on the forums, they are aware of the problem, so it should not take too long to have a fix.
While this is fixed, I will use TestDriven.NET to run my tests. But I will miss the great Resharper UI ;)
您是否查看过 Visual Studio 2010 中的编译设置?
为了隐藏他们无法让最新的调试器在 64 位中运行的情况,微软决定将 .Net 应用程序的默认编译从 ANY_CPU 切换到 32 位 x86。
这可能会给你带来问题。
Did you look at your compile settings in Visual Studio 2010?
For hiding their inability to get their newest debugger running in 64bit Microsoft decided to switch the default compilation for .Net applications from ANY_CPU to 32bit x86.
That could create your problems.
无法从 NHibernate.Driver.SQLite20Driver、NHibernate、Version=2.1.2.4000、Culture=neutral、PublicKeyToken=aa95f207798dfdb4 创建驱动程序
解决方案:
testsettings:
选择主机
选择在 64 位机器上的 64 位进程中运行测试
希望我能提供帮助。
快乐编码
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