2012-05-02 60 views
10

我已經使用NGEN創建了我的應用程序使用的幾個組合件的原始圖像。但是,這些圖像在運行應用程序時未加載,我不知道爲什麼。使用NGEN創建的.NET本機映像未加載

這是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. 

而且從ngen.exe有關組裝的信息:

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 

我用位於C ngen.exe:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \和我的程序集的目標框架是.NET Framework 4.在創建本機映像後,我沒有重新編譯程序集。

任何幫助,將不勝感激。 C:

回答

10

大會經理從裝\的Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ clr.dll

你的過程是在64位模式下運行時,默認用64位操作系統上的AnyCPU目標。這需要您運行ngen.exe的64位版本。一定要選擇正確的Visual Studio命令提示符。在「開始」菜單中有兩個爲64位工具設置環境的環境,名爲「Visual Studio x64 Win64命令提示符(2010)」。

+0

真棒,感謝您的快速和正確的答案漢斯。 – Odsh

+1

+1對於記錄完備的問題,您可以很輕鬆地爲您提供幫助。 –

相關問題