【问题标题】:Visual Studio 2012 unit tests try to load older versions of assembliesVisual Studio 2012 单元测试尝试加载旧版本的程序集
【发布时间】:2012-11-03 03:45:43
【问题描述】:

我似乎无法运行任何单元测试。所有错误都在以下几行:

    Test method TvQueue.UnitTesting.TheTvDb.TheTvDbServiceTest.GetShowbasicTest threw exception: 
System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.=== Pre-bind state information ===
LOG: User = JKRTABLET\Jan
LOG: DisplayName = System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Jan/Documents/Visual Studio 2012/Projects/TvQueue/TvQueue.UnitTesting/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : TvQueue.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\JetBrains\ReSharper\v7.0\Bin\JetBrains.ReSharper.TaskRunner.CLR4.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
LOG: Attempting download of new URL file:///C:/Users/Jan/Documents/Visual Studio 2012/Projects/TvQueue/TvQueue.UnitTesting/bin/Debug/System.Windows.DLL.
LOG: Attempting download of new URL file:///C:/Users/Jan/Documents/Visual Studio 2012/Projects/TvQueue/TvQueue.UnitTesting/bin/Debug/System.Windows/System.Windows.DLL.
LOG: Attempting download of new URL file:///C:/Users/Jan/Documents/Visual Studio 2012/Projects/TvQueue/TvQueue.UnitTesting/bin/Debug/System.Windows.EXE.
LOG: Attempting download of new URL file:///C:/Users/Jan/Documents/Visual Studio 2012/Projects/TvQueue/TvQueue.UnitTesting/bin/Debug/System.Windows/System.Windows.EXE.

    at TvQueue.Data.TheTvDb.TheTvDbService.<GetShow>d__8.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start(ref TStateMachine stateMachine)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start(ref TStateMachine stateMachine)
   at TvQueue.Data.TheTvDb.TheTvDbService.GetShow(Int64 theTvDbId)
   at TvQueue.UnitTesting.TheTvDb.TheTvDbServiceTest.<GetShowbasicTest>d__0.MoveNext() in TheTvDbServiceTest.cs: line 19
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

我在开发 Windows Phone 8 代码时遇到了这个问题。出于某种原因,MSTest 想要加载旧版本的程序集(项目中实际引用的程序集是 4.x 或更高版本,MSTest 想要加载 2.x 版本)。

我怀疑这是配置问题,但我不知道如何解决。

感谢您的帮助。

【问题讨论】:

    标签: visual-studio-2012 mstest windows-phone-8


    【解决方案1】:

    请在How to use MSTest in VS2010 for Windows Phone 8 applications查看我的回答

    项目中实际引用的程序集是 4.x 或更高版本

    System.Windows, Version=2.0.6.0 不是旧版本,而是正确的新版本。而且您实际上看不到单个程序集的版本号,是否没有单个程序集之类的东西。

    请记住,主要变化是 Windows Phone 8 和 Windows RT 一样,不再使用直接程序集,而是使用 WinMD 文件,将多个程序集编译成单个 API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多