8

I'm one of those people who love the Edit and Continue in VS. Because of that I develop apps in 32-bit. But when I run a unit test in debug mode and I try to edit a line, I get the usual "Changes to 64-bit applications are not allowed." message. All my components are marked x86, nunit is installed as a 32-bit application. My system is 64-bit.
How can I force nunit to run as a 32-bit application?

Paw Baltzersen
  • 2,662
  • 3
  • 24
  • 33
  • Additional info: I did try to set the 32BIT corflag on both nunit-console.exe and nunit.exe. – Paw Baltzersen Sep 14 '10 at 07:01
  • You only need to mark the host process leave all others components at AnyCpu. make 100% sure that your host is marked as 32BIT+. Verify that the host that you modified is actually the host that you are running. At latest check in the task manager that your host is not 64 Bit (It will have a * next to it if its 32 bit) – Shay Erlichmen Sep 14 '10 at 07:05
  • I'm trying something else now. I'm running nunit through ReSharper, so it might be ReSharper's TaskRunner that's running in 64-bit. – Paw Baltzersen Sep 14 '10 at 07:13

2 Answers2

12

For Resharper 5, you can just set the Platform Target, of the assembly you are testing, to x86 (in the IDE's Properties for that project). The new Resharper 5 test runner apparently detects that and runs the tests as 32 bit. No need to mess with corflags.

John Rusk
  • 381
  • 3
  • 12
7

Ok I figured it out. It was indeed the ReSharper TaskRunner that was running as 64-bit, more precisely JetBrains.ReSharper.TaskRunner.CLR4.MSIL.exe. I first created a copy of the file, made it writeable and then forced it's 32BIT flag high:

>corflags JetBrains.ReSharper.TaskRunner.clr4.msil.exe /32bit+ /force

/force because it's signed.

There are several other TaskRunner assemblies but I found this to be the one I'm using (trial and error). Might need to do the same to the others if I run into other ReSharper 64-bit related problems.

Hope this will help others solve the same issue.

Paw Baltzersen
  • 2,662
  • 3
  • 24
  • 33
  • I found the warning message it gave confusing as I wasn't sure whether it was actually applying the 32bit change or not. But turns out it was :) – Jen Mar 06 '12 at 00:18
  • how come I keep getting "Could not open files for writing", even though I already closed all VS and I run the command line as admin? – Louis Rhys Apr 17 '13 at 03:46