質問

I am having trouble loading the that.dll contains my test classes that call into my work.dll.

I can do it nicely with a helloworld.dll but when I put the helloworld test in my test.dll, It cannot load, even after I remove my work.dll references from the test.dll

I think the problem her is that the path to the work.dll is not known by Fitness, how do I specify it? ( preferebly in the root page)

the error messages I get are:

System.BadImageFormatException: Could not load file or assembly 'file:///C:\Projects\..\test.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'file:///C:\Projects\..\test.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, 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.CurrentDomain.LoadAssembly(String assemblyPath)
   at fitSharp.Machine.Engine.ApplicationUnderTest.Assemblies.AddAssembly(String assemblyName)
   at fitSharp.Machine.Engine.ApplicationUnderTest.AddAssemblies(IEnumerable`1 assemblyNames)
   at fitnesse.fitserver.FitServer.ParseCommandLineArguments(IEnumerable`1 args)
   at fitnesse.fitserver.FitServer.Run(IList`1 CommandLineArguments)
   at fitnesse.fitserver.FitServer.Run(IList`1 commandLineArguments, Memory memory, ProgressReporter reporter)
   at fitSharp.Machine.Application.Shell.Run()
   at fitSharp.Machine.Application.Shell.Execute()
   at fitSharp.Machine.Application.Shell.Run(IList`1 commandLineArguments)

=== Pre-bind state information ===
LOG: User = kenneth
LOG: Where-ref bind. Location = C:\Projects\..\test.dll
LOG: Appbase = file:///C:/Projects/fitnesse/dotnet2/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Projects\fitnesse\dotnet2\Runner.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Projects/../test.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Does anyone have any clues/tips.

thanks kenneth

役に立ちましたか?

解決 2

The problem was running a 64 bit testrunner, and testing / loading 32 bit dlls. To solve this I ran CorFlags.exe on TestRunner.exe with the /32BIT+ flag set. you can get Corflags from the SDK.

他のヒント

You can only load DLLs that match the bitness of your application's process. That's what the BadImageFormatException is trying to tell you, that you've attempted to load an incompatible DLL.

So if you have a 32-bit (x86) process, you can only load 32-bit (x86) DLLs.
And if you have a 64-bit (x64) process, you can only load 64-bit (x64) DLLs.

The "Any CPU" compiler setting just means that the bitness of the process will match the native bitness of your machine: 64-bit on a 64-bit OS, 32-bit otherwise.

You will need to either obtain a version of the DLL that matches the bitness of your application, or re-compile your application to target a different bitness.

Have you checked out the FitSharp instructions for adding your code to the classpath:

Based on the BadImageFormatException, you appear to have a mismatch between your DLL's .net version and the test runner's .net version.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top