不会加载使用 NGEN 创建的 .NET 本机映像



我已经使用 NGEN 创建了我的应用程序使用的几个程序集的本机映像。但是,运行应用程序时不会加载这些图像,我不知道为什么。

这是来自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:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll
Running under executable  C:MyDirMyApp.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:MyDirMyAssembly.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:MyDirMyAssembly.dll
NGEN Roots that depend on "C:MyDirMyAssembly.dll":
C:MyDirMyAssembly.dll
Native Images:
MyAssembly, Version=1000.0.0.0, Culture=neutral, PublicKeyToken=null

我使用了位于 C:\Windows\Microsoft.NET\Framework\v4.0.30319\ 中的 ngen.exe,我的程序集的目标框架是 .NET Framework 4。创建本机映像后,我没有重新编译程序集。

任何帮助将不胜感激。

程序集管理器加载自:C:\Windows\Microsoft.NET\ Framework64\v4.0.30319\clr.dll

您的进程在 64 位模式下运行,默认为 64 位操作系统上的 AnyCPU 目标。 这要求您运行 64 位版本的 ngen.exe。 请务必选择正确的 Visual Studio 命令提示符。 有两个,为64位工具设置环境的一个在"开始"菜单中命名为"Visual Studio x64 Win64命令提示符(2010)"。

最新更新