I have (only) Visual Studio 2010. I am trying to run my unit tests from the command line. All my development work is in my home directory on the Linux server that I shared with Samba. When I try to start NUnit, I get this error:
Unhandled Exception: System.TypeInitializationException: The type initializer for 'NUnit.ConsoleRunner.Runner' threw an exception.
I tried using caspol.exe as described here: Edit and run .NET projects from network shares
>caspol -addgroup 1.2 -url file:
It has no obvious effect.
In the other instructions, tell me to find the Microsoft.NET Security Policy tool in the "Administration" section of the control panel, but I do not have such a tool. (Is it because I only have Visual Studio 2010 and not earlier versions? I use the 64-bit version of Windows 7 Pro, if that matters.)
I just want .NET to believe that this directory is on my own computer, not on the intranet. I do not want any of this code to be launched from a network share during deployment, only as part of the development. I also do not want to blindly trust all network resources, although even this would be a more acceptable solution than copying everything to a local drive every time I want to run a test.
I would rather not sign anything with strong names at this stage of development. (And I'm not even sure if this will help, as NUnit does not seem to work before it even loaded my assembly.)
EDIT. In the end, it turned out that I was trying to solve the wrong problem. Finding out how to get NUnit to run .NET 4.0 tests without a subprocess, I found this:
http://frater.wordpress.com/2010/05/04/debugging-nunit-tests-under-visual-studio-2010/
It says:
According to this page, you should also add this line under the runtime [in nunit-console.exe.config] element:
<loadFromRemoteSources enabled="true" />
This allows you to download libraries downloaded from a remote site (such as a website) with full trust. I'm not sure why this was necessary and indeed, my application debugged NUnit just fine without it. However, if you have problems, you can try.
This fixed my problem for me without having to guess with caspol.