.net 加载dll时的Fitnesse问题
加载包含调用到work.dll的测试类的.dll时遇到问题 我可以很好地使用helloworld.dll,但当我将helloworld测试放在test.dll中时,它无法加载,即使我从test.dll中删除了work.dll引用 我认为她的问题在于适合度不知道work.dll的路径,如何指定它?(最好在根页面中) 我收到的错误消息如下:.net 加载dll时的Fitnesse问题,.net,fitnesse,.net,Fitnesse,加载包含调用到work.dll的测试类的.dll时遇到问题 我可以很好地使用helloworld.dll,但当我将helloworld测试放在test.dll中时,它无法加载,即使我从test.dll中删除了work.dll引用 我认为她的问题在于适合度不知道work.dll的路径,如何指定它?(最好在根页面中) 我收到的错误消息如下: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Proj
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.
有人有任何线索/提示吗
谢谢
kenneth您是否查阅了FitSharp关于将代码添加到类路径的说明:
BadImageFormatException
试图告诉您的,您试图加载不兼容的DLL
因此,如果您有32位(x86)进程,则只能加载32位(x86)DLL。如果有64位(x64)进程,则只能加载64位(x64)DLL “任意CPU”编译器设置只意味着进程的位将与机器的本机位匹配:64位操作系统上为64位,否则为32位
您需要获取与应用程序位匹配的DLL版本,或者重新编译应用程序以针对不同的位。您只能加载与应用程序进程位匹配的DLL。这就是
BadImageFormatException
试图告诉您的,您试图加载不兼容的DLL
因此,如果您有32位(x86)进程,则只能加载32位(x86)DLL。如果有64位(x64)进程,则只能加载64位(x64)DLL “任意CPU”编译器设置只意味着进程的位将与机器的本机位匹配:64位操作系统上为64位,否则为32位
您需要获取与应用程序位匹配的DLL版本,或者重新编译应用程序以针对不同的位。问题在于运行64位testrunner,以及测试/加载32位DLL。 为了解决这个问题,我在TestRunner.exe上运行了CorFlags.exe,并设置了/32BIT+标志。
您可以从SDK获取Corflags。问题在于运行64位testrunner,以及测试/加载32位DLL。 为了解决这个问题,我在TestRunner.exe上运行了CorFlags.exe,并设置了/32BIT+标志。
您可以从SDK中获取Corflags。我已经做了进一步的调查,问题似乎取决于我编译到的目标平台的类型。当我进行一个虚拟测试并编译到任何CPU时,它似乎工作得很好。但是当我链接到work.dll(编译为x86)时,它就不再加载了。(由于86/64问题,我收到一个MSIL警告)关于如何解决这个问题的任何想法(除了将引用的项目编译为64位-我在64位win 7上运行)?我已经进行了进一步调查,问题似乎取决于我编译的目标平台的类型。当我进行一个虚拟测试并编译到任何CPU时,它似乎工作得很好。但是当我链接到work.dll(编译为x86)时,它就不再加载了。(由于86/64问题,我收到了一个MSIL警告)关于如何解决这个问题的任何想法(除了将引用的项目编译为64位-我在64位win 7上运行)?是的,看起来你是正确的。问题是我在64位mashine上运行,在那里我正在开发32位dll。显然,fitnesse testrunner期望的是64位,而不是32位。是的,看起来你是正确的。问题是我在64位mashine上运行,在那里我正在开发32位dll。显然fitnesse testrunner期望的是64位,而不是32位。