Loading
oct 29

When using the sonar-csharp-core-plugin with Gallio (for executing Unit Tests), you may encounter the following error An attempt was made to load a program with an incorrect format:

[INFO] Running the tests.
[INFO] A fatal exception occurred while running tests.  Possible causes include invalid test runner parameters and stack overflows.
[INFO] 	Gallio.Model.ModelException: An exception occurred while invoking a test driver. ---> Gallio.Model.ModelException: Gallio.Model.ModelException: Could not load test assembly from 'X:\XXXXX\MyDLL.dll'. ---> System.BadImageFormatException: Could not load file or assembly 'file:///X:\XXXXX\MyDLL.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
[INFO] 	   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
[INFO] 	   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
[INFO] 	   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
[INFO] 	   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
[INFO] 	   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
[INFO] 	   at Gallio.Runtime.Loader.DefaultAssemblyLoader.LoadAssemblyFrom(String assemblyFile) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Runtime\Loader\DefaultAssemblyLoader.cs:line 86
[INFO] 	   at Gallio.Model.DotNetTestDriver.ExploreOrRunTask.LoadAssembly(String assemblyPath) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Model\DotNetTestDriver.cs:line 330
[INFO] 	   --- End of inner exception stack trace ---
[INFO] 	   at Gallio.Model.DotNetTestDriver.ExploreOrRunTask.LoadAssembly(String assemblyPath) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Model\DotNetTestDriver.cs:line 337

After many attempts, I found the error : the build was being executed on a 64bits machine while the build was a 32bits.
The solution is to change the sonar.gallio.runner parameter :

 
    <sonar.gallio.runner>IsolatedProcess</sonar.gallio.runner>
 
Tags :

Creative Commons License
Blog Infin-It par Infin-It est mis à disposition selon les termes de la licence Creative Commons Paternité-Pas d'Utilisation Commerciale 2.0 France.