Unit Test Runner failed to load test assembly
Hello,
I am unable to use Resharper's unit test runner anymore. I feel like the issue started occuring when I installed Nunit, but I can't be sure because uninstalling NUnit didn't resolve the issue. This is the error message that I get is:
[Window Title]
ReSharper Test Runner
[Main Instruction]
Unit Test Runner failed to load test assembly
[Content]
System.BadImageFormatException: Could not load file or assembly 'C:\Users\rtaylor\Documents\Visual Studio 2010\Projects\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
[Expanded Information]
at System.Reflection.AssemblyName.nGetFileInformation(String s)
at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at JetBrains.ReSharper.UnitTestRunner.nUnit.NUnitTaskRunner.ExecuteRecursive(TaskExecutionNode node) in c:\BuildAgent\work\c4b2ec378d776aaa\src\UnitTestRunner.nUnit\src\NUnitTaskRunner.cs:line 112
[^] Hide details [OK]
Running the tests directly inside the NUnit GUI works as expected and I have tried changing the Nunit settings inside Resharper's options without success.
Thanks,
Ryan
Attachment(s):
Untitled2.png
Please sign in to leave a comment.
I had this problem. Have you tried to switch to R# NUnit - check the box next to "Nunit 2.5.9 provided with ReSharper". This was a problem I reported before, that got fixed and is working for me in 2141 - haven't tried the later builds.
Hi sparky2708,
Thanks, however I did try that without success. As it turns out I am running 6.0.2141.9, so that is interesting that it works for you with the same version.
Thanks,
Ryan
Some more information: If I switch my project to use .Net 3.5, I can use the Unit Test runner, but as soon as I switch to .Net 4, it doesn't work. Unfortunately, that is not a tenable workaround.
Thanks,
Ryan
Update: It appears that some of the JetBrains.ReSharper.TaskRunner.*.exe.config files needed to be manually changed to work with .Net 4. Once I added:
<startup> <requiredRuntime version="v4.0.30319" /></startup> at the bottom of the configuration block in two files, everything started working again.
For WPF applications, I needed to update: C:\Program Files (x86)\JetBrains\ReSharper\v6.0\Bin\JetBrains.ReSharper.TaskRunner.exe.config
For MVC3 web applications, I needed to update: C:\Program Files (x86)\JetBrains\ReSharper\v6.0\Bin\JetBrains.ReSharper.TaskRunner.MSIL.exe.config
Hopefully this will help someone else and help point the Resharper guys in the right direction for updating the files as necessary.
Thanks,
Ryan
I tried making these modifications - no luck unfortunately. I'm still getting the same error.
This isn't exactly related to the original post, but I found this post while searching for a solution to my problem, so maybe it will help others.
My problem relates to running unit tests with Resharper when the code is on a networked drive (which it has to be, since our version control is IBM Rational ClearCase). Resharper doesn't like that the code is not running in full trust (or whatever it is). I fixed this by adding <loadFromRemoteSources enabled="true" /> to some .exe.config files to make resharper happy. I opened the following files (path depends on version of resharper) and added <loadFromRemoteSources enabled="true" /> in <runtime> in <configuration> (as in screenshot).
C:\Program Files (x86)\JetBrains\ReSharper\v6.1\Bin\JetBrains.ReSharper.TaskRunner.CLR4.exe.config
C:\Program Files (x86)\JetBrains\ReSharper\v6.1\Bin\JetBrains.ReSharper.TaskRunner.CLR4.MSIL.exe.config
C:\Program Files (x86)\JetBrains\ReSharper\v6.1\Bin\JetBrains.ReSharper.TaskRunner.CLR4.x64.exe.config
C:\Program Files (x86)\JetBrains\ReSharper\v6.1\Bin\JetBrains.ReSharper.TaskRunner.exe.config
C:\Program Files (x86)\JetBrains\ReSharper\v6.1\Bin\JetBrains.ReSharper.TaskRunner.MSIL.exe.config
C:\Program Files (x86)\JetBrains\ReSharper\v6.1\Bin\JetBrains.ReSharper.TaskRunner.x64.exe.config
Even though our code targets .NET 2, apparently R# is using the CLR4 test runner, so it was necessary to change those .config files as well as the normal ones. I just changed all of them to cover all the bases. (Note, the files are readonly, so you'll need to change that to modify them.)
For reference, the exact error message I got was:
[Window Title]
ReSharper Test Runner
[Main Instruction]
Unit Test Runner failed to load test assembly
[Content]
System.IO.FileLoadException: Could not load file or assembly 'file:///Y:\Path\to\my.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
[V]
[Buttons]
[Header=_OK, Content=]
[Expanded Information]
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at JetBrains.ReSharper.UnitTestRunner.nUnit.NUnitTaskRunner.ExecuteRecursive(TaskExecutionNode node)
at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.Execute(TaskExecutionNode node)