从 NAnt 0.91-alpha2 启动时,NUnit 2.4.6 无法找到 log4n 1.2.10

发布于 2024-09-28 15:46:14 字数 2506 浏览 10 评论 0原文

我有一个 .NET 3.5 Web 应用程序,并且正在添加 Silverlight 4。我可以在 VS 2010 中构建和测试整个项目。我的程序集仍然以 3.5 为目标。我必须将 NAnt 从 .85 升级到 .91-alpha2 才能使构建完全正常工作,并且我必须使用对 msbuild v4.0.30319 的调用而不是 NAnt 的任务。现在一切都正常了(尽管如果有人有改进建议,我愿意接受)。

构建完成后,NAnt 启动单元测试。我的问题是它立即失败,因为 NUnit 找不到正确的 log4n.dll。输出如下(添加省略号以混淆某些文件夹名称)。 NAnt 使用 log4n 1.2.9,NUnit 使用 1.2.10。每个应用程序在其安装目录中都有正确的版本。 NAnt 加载其版本,该版本在启动 NUnit 时正在使用,但我不明白为什么会发生冲突。我怀疑这个问题与 NAnt .91-alpha2 有关,而且我想不出解决方法。

 [exec] Unhandled Exception:
 [exec] System.TypeInitializationException: The type initializer for 'NUnit.Core.RemoteTestRunner' threw an exception.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' 
or one of its dependencies. The system cannot find the file specified.
 [exec] File name: 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821'
 [exec]    at NUnit.Core.RemoteTestRunner..cctor()
 [exec] 
 [exec] Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
 [exec] Running under executable  C:\Program Files\NUnit 2.4.6\bin\nunit-console.exe
 [exec] --- A detailed error log follows. 
 [exec] 
 [exec] === Pre-bind state information ===
 [exec] LOG: User = ...
 [exec] LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
 [exec]  (Fully-specified)
 [exec] LOG: Appbase = file:///c:/AutomatedBuild/sourcecode/.../bin/Debug
 [exec] LOG: Initial PrivatePath = NULL
 [exec] Calling assembly : nunit.core, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77.
 [exec] ===
 [exec] LOG: This bind starts in default load context.
 [exec] LOG: No application configuration file found.
 [exec] LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
 [exec] LOG: Post-policy reference: log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net.DLL.
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net/log4net.DLL.
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net.EXE.
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net/log4net.EXE.
 [exec] 
 [exec]    --- End of inner exception stack trace ---

I have a .NET 3.5 web application, and I am adding Silverlight 4. I can build and test the whole project in VS 2010. My assemblies still targets 3.5. I had to upgrade NAnt from .85 to .91-alpha2 to get the build to work at all, and I had to use an call to msbuild v4.0.30319 rather than NAnt's task. That all works now (though if anybody has suggestions for improvement, I'm open to them).

After the build, NAnt launches unit tests. My problem is that it immediately fails because NUnit can't find the right log4n.dll. The output is below (elipses added to obfuscate some folder names). NAnt uses log4n 1.2.9, and NUnit uses 1.2.10. Each application has the correct version in its install directory. NAnt loads its version, which is in use when it launches NUnit, but I don't see why there is a conflict. I suspect the problem has something to do with NAnt .91-alpha2, and I can't think of a work-around.

 [exec] Unhandled Exception:
 [exec] System.TypeInitializationException: The type initializer for 'NUnit.Core.RemoteTestRunner' threw an exception.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' 
or one of its dependencies. The system cannot find the file specified.
 [exec] File name: 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821'
 [exec]    at NUnit.Core.RemoteTestRunner..cctor()
 [exec] 
 [exec] Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
 [exec] Running under executable  C:\Program Files\NUnit 2.4.6\bin\nunit-console.exe
 [exec] --- A detailed error log follows. 
 [exec] 
 [exec] === Pre-bind state information ===
 [exec] LOG: User = ...
 [exec] LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
 [exec]  (Fully-specified)
 [exec] LOG: Appbase = file:///c:/AutomatedBuild/sourcecode/.../bin/Debug
 [exec] LOG: Initial PrivatePath = NULL
 [exec] Calling assembly : nunit.core, Version=2.4.6.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77.
 [exec] ===
 [exec] LOG: This bind starts in default load context.
 [exec] LOG: No application configuration file found.
 [exec] LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
 [exec] LOG: Post-policy reference: log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net.DLL.
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net/log4net.DLL.
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net.EXE.
 [exec] LOG: Attempting download of new URL file:///c:/AutomatedBuild/sourcecode/.../bin/Debug/log4net/log4net.EXE.
 [exec] 
 [exec]    --- End of inner exception stack trace ---

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩心态 2024-10-05 15:46:14

根据 OP,该错误已通过更新 NUnit 解决:

NUnit 2.4.6 被我安装的某些东西破坏了,因为当我单独运行 NUnit GUI 时收到错误。我安装的新版本 (2.5.7) 上没有出现错误。

According the OP, the error was resolved by updating NUnit:

NUnit 2.4.6 was broken by something I installed, because I get the error when I run the NUnit GUI alone. I do not get the error on a new version I installed (2.5.7).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文