2013-08-23 13 views
5

Sto provando a eseguire alcuni test delle unità che eseguono alcuni comandi SQL direttamente su un database Oracle e ottengo la seguente eccezione quando i test di unità siano avviati:System.IO.FileNotFoundException: Impossibile caricare il file o l'assembly 'Oracle.DataAccess, ... quando si eseguono i test delle unità

Testmethod1 ha gettato un'eccezione:
System.IO.FileNotFoundException: Impossibile caricare il file o l'assembly 'Oracle.DataAccess, Version = 4.112.3.0, Culture = neutral, PublicKeyToken = 89b483f429c47342 'o una delle sue dipendenze. Il sistema non trova il file specificato.

Ho Oracle.DataAccess nei riferimenti del progetto (aggiunto tramite NuGet) e ho installato il Provider di dati Oracle.

Ho anche altri progetti che utilizzano Oracle.DataAccess eseguiti in questa macchina senza problemi. Sembra che solo Microsoft.Net Unit Test Framework (MSTest) non sia in grado di caricare l'assembly.

Questo è il log tratto da Fusion Log Viewer:

*** Assembly Binder Log Entry (23/08/2013 @ 04:50:07 p.m.) *** 

The operation failed. 
Bind result: hr = 0x80070002. The system cannot find the file specified. 

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll 
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\QTAgent32_40.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = ... 
LOG: DisplayName = Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342 
(Fully-specified) 
LOG: Appbase = file:///...C:/<solution_folder>.../TestResults/.../Out 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = QTAgent32_40.exe 
Calling assembly : ...<project_name>..., Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\...<solution_folder>...\TestResults\...\Out\...<project_name>....DLL.config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Post-policy reference: Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342 
LOG: GAC Lookup was unsuccessful. 
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess.DLL. 
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess/Oracle.DataAccess.DLL. 
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess.EXE. 
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess/Oracle.DataAccess.EXE. 
LOG: All probing URLs attempted and failed. 

Si afferma l'assemblea non è stata trovata nel GAC, ma ho trovato: C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342\Oracle.DataAccess.dll\

E 'anche interessante notare è che il il registro precedente mostra QTAgent32_40.exe anche se ho selezionato nel menu Visual Studio TEST -> Test Settings -> Default Processor Architecture -> X64. Prima di farlo, invece, ricevevo un BadImageFormatException.

Note aggiuntive:

  • L'Oracle Data Provider che ho installato è la versione a 64 bit.
  • Il riferimento ha già Copy Local=True
+1

attivare la registrazione di fusione per vedere se questo aiuta a capire che cosa file manca: http://www.hanselman.com/blog/CommentView.aspx?guid=3654c8f3-c5c3-4dee-a01f-c9a8da3ef2fa –

+0

didn' lo so. Grazie. L'ho appena aggiunto alla domanda – mmutilva

+0

I tuoi test funzionano come un processo a 32 bit? –

risposta

5

trovato il problema.

C'era un file .testsettings che obbligava i test a essere eseguiti in modalità 32 bit indipendentemente da me selezionando TEST -> Test Settings -> Default Processor Architecture -> X64.

La cosa strana è che se seleziono X86 ho la corretta BadImageFormatException in fase di esecuzione, mentre se l'architettura è costretto nel file .testsettings ottengo FileNotFoundException, che è un po 'fuorviante.

Problemi correlati