不能 运行 在 Visual Studio 2015 年进行任何单元测试
Cannot run any unit tests in Visual Studio 2015
我最近下载了 Visual Studio 2015 并将一个旧项目导入其中。
问题是现在 none 的单元测试 运行,相反我得到了可怕的 BadImageFormatException
Unable to get type GameTests.UnitTest1. Error: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\...\bin\Debug\GameTests.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:\Users\...\bin\Debug\GameTests.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName, String assemblyName)
起初我以为我将现有项目转移到VS2015时可能有问题,但我尝试了一个新创建的项目,并且发生了同样的事情。我也尝试过 MS UnitTestFramework 和 NUnit。似乎没有任何帮助。
有什么想法吗?
P.S。 - 我还将平台目标设置为 x86 并检查我的所有项目是否具有相同的目标框架。
你试过了吗changing your app config?
我最近下载了 Visual Studio 2015 并将一个旧项目导入其中。 问题是现在 none 的单元测试 运行,相反我得到了可怕的 BadImageFormatException
Unable to get type GameTests.UnitTest1. Error: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\...\bin\Debug\GameTests.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:\Users\...\bin\Debug\GameTests.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName, String assemblyName)
起初我以为我将现有项目转移到VS2015时可能有问题,但我尝试了一个新创建的项目,并且发生了同样的事情。我也尝试过 MS UnitTestFramework 和 NUnit。似乎没有任何帮助。
有什么想法吗?
P.S。 - 我还将平台目标设置为 x86 并检查我的所有项目是否具有相同的目标框架。
你试过了吗changing your app config?