fitSharp with .NET 4.0 hangs Fitnesse test
I ran into an issue with fitSharp with .NET 4.0. I built a very simple test page, with a ColumnFixture test. Clicked the test button, and Fitnesse hung.
I made several edits to the test page, and still had no luck. Just hanging, with no indication what was causing the problem. So, I went to commandline and manually executed the fitSharp runner (Runner.exe) with the command line that was being generated from the test page. Here are the results that I got:
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\tools\fitSharp\fit.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\tools\fitSharp\fit.dll' ---> 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.
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 fitSharp.Machine.Engine.ApplicationUnderTest.AddAssembly(String assemblyName)
at fitSharp.Machine.Application.Shell.ParseArguments(String[] commandLineArguments)
at fitSharp.Machine.Application.Shell.RunInCurrentDomain(String[] commandLineArguments)
at fitSharp.Machine.Application.Shell.Run(String[] commandLineArguments)
.NET 4.0 has made some changes to the default CAS policies (some details here.
The resolution to the problem? Simply creating a configuration file for Runner.exe to enable the loadFromRemoteSources option for the assembly.
Create a file called Runner.exe.config in the fitSharp folder (with Runner.exe), and add the following to the file:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
Re-run the test in Fitnesse, and all should be good!