Fitnesse加载DLL的问题

时间:2013-07-19 13:39:53

标签: .net fitnesse

我无法加载that.dll包含调用my work.dll的测试类。

我可以使用helloworld.dll很好地完成它但是当我在我的test.dll中放入helloworld测试时,即使我从test.dll中删除了我的work.dll引用它也无法加载

我认为她的问题是Fitness不知道work.dll的路径,我该如何指定它? (最好在根页面)

我收到的错误消息是:

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.

有没有人有任何线索/提示。

感谢 肯尼斯

4 个答案:

答案 0 :(得分:3)

您只能加载与应用程序进程的位数匹配的DLL。这就是BadImageFormatException试图告诉你的,你试图加载一个不兼容的DLL。

因此,如果您有32位(x86)进程,则只能加载32位(x86)DLL。
如果你有一个64位(x64)进程,你只能加载64位(x64)DLL。

“任何CPU”编译器设置只是意味着进程的位数将与您机器的本机位相匹配:64位操作系统上为64位,否则为32位。

您需要获取与应用程序位数相匹配的DLL版本,或者重新编译应用程序以定位不同的位数。

答案 1 :(得分:1)

问题是运行64位testrunner,测试/加载32位dll。 为了解决这个问题,我在TestRunner.exe上运行了CorFlags.exe并设置了/ 32BIT +标志。 你可以从SDK获得Corflags。

答案 2 :(得分:0)

您是否已检查FitSharp指令,以便将代码添加到类路径中:

答案 3 :(得分:0)

基于BadImageFormatException,您的DLL的.net版本与测试运行器的.net版本之间似乎不匹配。