2013-07-19 78 views
1

我有問題加載that.dll包含我的測試類,調用到我的work.dll。Fitnesse問題加載DLL

我可以用helloworld.dll很好地做到這一點,但是當我把HelloWorld的測試中我Test.dll的,它不能加載,即使我從Test.dll的

刪除我work.dll引用認爲她的問題是通過Fitness不知道work.dll的路徑,我該如何指定它? (preferebly根頁)

錯誤消息我得到的是:

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. 

沒有人有任何線索/提示。

感謝 肯尼斯

+0

我已經進一步調查了,問題似乎取決於我正在編譯的目標平臺的類型。當我做一個虛擬測試並編譯到AnyCPU時,它看起來很好地工作。但是,當我鏈接到work.dll - 編譯爲x86時,它不再加載。 (由於86/64問題,我得到了一個MSIL警告)關於如何解決這個問題的任何想法(除了將引用的項目編譯爲64位 - 我在64位win 7上運行)? – kfn

回答

1

問題是運行64位testrunner,並測試/加載32位dll。 爲了解決這個問題,我在TestRunner.exe上運行了CorFlags.exe並設置了/ 32BIT +標誌。 你可以從SDK獲取Corflags。

0

基礎上BadImageFormatException,你的出現在你的DLL的.net版本和測試運行器的.net ve之間不匹配rsion。

3

您只能加載匹配應用程序進程位數的DLL。這就是BadImageFormatException試圖告訴你,你試圖加載不兼容的DLL。

因此,如果您有32位(x86)進程,則只能加載32位(x86)DLL。
如果您有64位(x64)進程,則只能加載64位(x64)DLL。

「任何CPU」編譯器設置僅意味着進程的位數將與本機的本地位數相匹配:64位操作系統上爲64位,否則爲32位。

您將需要獲取與您的應用程序的位數相匹配的DLL版本,或者重新編譯您的應用程序以針對不同的位數。

+0

是的,它看起來像你一樣。問題是我正在64位mashine上運行,我在開發32位dll。顯然fitnesse testrunner會期望64位,而不是32位。 – kfn