2012-05-02 21 views
10

Ho utilizzato NGEN per creare immagini native di diversi assiemi utilizzati dalla mia applicazione. Tuttavia, quelle immagini non vengono caricate durante l'esecuzione dell'applicazione e non ho idea del perché.Le immagini native .NET create con NGEN non vengono caricate

Si tratta di un registro tipico fuslogvw:

*** Assembly Binder Log Entry (2/05/2012 @ 13:29:04) *** 

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

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll 
Running under executable C:\MyDir\MyApp.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = ***\*** 
LOG: DisplayName = MyAssembly, Version=1000.0.0.0, Culture=neutral, PublicKeyToken=null (Fully-specified) 
LOG: Appbase = file:///C:/MyDir/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = MyApp.exe 
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. 
=== 
LOG: Start binding of native image MyAssembly, Version=1000.0.0.0, Culture=neutral, PublicKeyToken=null. 
WRN: No matching native image found. 
LOG: IL assembly loaded from C:\MyDir\MyAssembly.dll. 

e le informazioni desunte Ngen.exe su quell'assemblea:

C:\MyDir>ngen display MyAssembly.dll 
Microsoft (R) CLR Native Image Generator - Version 4.0.30319.1 
Copyright (c) Microsoft Corporation. All rights reserved. 

NGEN Roots: 

C:\MyDir\MyAssembly.dll 

NGEN Roots that depend on "C:\MyDir\MyAssembly.dll": 

C:\MyDir\MyAssembly.dll 

Native Images: 

MyAssembly, Version=1000.0.0.0, Culture=neutral, PublicKeyToken=null 

ho usato il Ngen.exe si trova in C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ e il framework di destinazione dell'assembly è .NET Framework 4. Non ho ricompilato l'assembly dopo aver creato l'immagine nativa.

Qualsiasi aiuto sarebbe apprezzato.

risposta

10

Assemblea direttore caricato da: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ clr.dll

Il vostro processo è in esecuzione in modalità a 64 bit, il default con il target AnyCPU su un sistema operativo a 64 bit. Ciò richiede che venga eseguita la versione a 64 bit di ngen.exe. Assicurati di selezionare il prompt dei comandi di Visual Studio appropriato. Ce ne sono due, quello che imposta l'ambiente per gli strumenti a 64 bit è denominato "Visual Studio x64 Win64 Command Prompt (2010)" nel menu Start.

+0

Impressionante, grazie per la risposta rapida e corretta Hans. – Odsh

+1

+1 per una domanda molto ben documentata, hai reso facile aiutarti. –