简体   繁体   English

Ngen错误,因为“ Mscorlib.dll没有本地映像”(仅x64,仅.NET 4.0)

[英]Ngen error because “Mscorlib.dll does not have a native image” (x64 only, .NET 4.0 only)

I'm trying to generate a native image of my .NET 4.0 application using Ngen using a 64-bit Windows 7. When Platform is set to x64 (or Any CPU ) - Ngen fails, complaining that ' NGen cannot proceed because Mscorlib.dll does not have a native image .' 我正在尝试使用64位Windows 7使用Ngen生成.NET 4.0应用程序的本机映像。当Platform设置为x64(或任何CPU )时-Ngen失败,抱怨' NGen无法继续,因为Mscorlib.dll没有本地图像

When compiling as x86 and using the appropriate Ngen - it works fine. 当编译为x86并使用适当的Ngen时-可以正常工作。 Also, when changing the .NET version to 2.0 - it works. 另外,将.NET版本更改为2.0时,它也可以工作。 (When trying to Ngen the x64 application with the x86 Ngen, it tells me I should use the 64-bit version.) (当尝试使用x86 Ngen将Ngen x64应用程序使用时,它告诉我应该使用64位版本。)

More information : 更多信息

This is (part of) what I see in CMD: The ellipses (= ...) are present in the original. 这是我在CMD中看到的(一部分):椭圆(= ...)存在于原件中。

1> Compiling assembly mscorlib , Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 (CLR v4.0.30319) ... 1> 编译程序集mscorlib ,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089(CLR v4.0.30319)...

1> mscorlib , Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 1> mscorlib ,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089

.

2> Compiling assembly Accessibility, Version=4.0.0.0, Culture=neutral, Public KeyToken=b03f5f7f11d50a3a (CLR v4.0.30319) ... 2>编译程序集可访问性,版本= 4.0.0.0,区域性=中性,公共KeyToken = b03f5f7f11d50a3a(CLR v4.0.30319)...

.

2>Ngen failed to generate native code for image Accessibility, Version=4.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a because of the following error: NGen cannot proceed because Mscorlib.dll does not have a native image (Exception from HRESULT: 0x80131F06) 2> Ngen无法生成用于图像可访问性的本机代码,版本= 4.0.0.0,Culture =中性,PublicKeyToken = b03f5f7f11d50a3a,因为以下错误: NGen无法继续,因为Mscorlib.dll没有本机图像 (HRESULT的异常:0x80131F06 )

Searching inside C:\\Windows\\assembly I found 3 mscorlib.dll 's. C:\\Windows\\assembly搜索,我发现了3个mscorlib.dll One in GAC_32 , one in GAC_64 (both in subfolders beginning with 2.0.0.0) and one in a subfolder temp . 一个在GAC_32 ,一个在GAC_64 (都在以2.0.0.0开头的子文件夹中),另一个在子文件夹temp

When searching inside C:\\Windows\\Microsoft.NET I found six of them: two under assembly (in GAC 's 32 and 64 ) both in folders that begin with 'v4.0...', and four in Framework 's: 2 in Framework , and two in Framework64 (in each - one in 'v2.0...' and one in 'v4.0...'). C:\\Windows\\Microsoft.NET内部搜索时,我发现其中有六个:两个在assembly下(在GAC3264 )都在以'v4.0 ...'开头的文件夹中,四个在Framework的下:2 框架Framework64两(在每个-一个在“V2.0 ......”,一个在“V4.0 ...”)。

Does this mean that only .NET 2.0 mscorlib's are really run as native images (when needed)? 这是否意味着只有.NET 2.0 mscorlib才能真正作为本机映像运行(需要时)? And why doesn't Ngen succeed in saving native images of .NET 4.0? Ngen为什么不能成功保存.NET 4.0的本机映像?

Bottom line : How do I create a native image of a .NET 4.0 application that targets x64? 底线 :如何创建针对x64的.NET 4.0应用程序的本机映像?

This is unhealthy. 这不健康。 The ngen-ed image of mscorlib.dll should have been created when .NET was installed on your machine. 在计算机上安装.NET时,应该已经创建了mscorlib.dll的ngen映像。 It is located in c:\\windows\\assembly\\NativeImages_v4.0.30319_64\\mscorlib\\ab0a8fc3d086a3aaf942f366a12a9185\\mscorlib.ni.dll. 它位于c:\\ windows \\ assembly \\ NativeImages_v4.0.30319_64 \\ mscorlib \\ ab0a8fc3d086a3aaf942f366a12a9185 \\ mscorlib.ni.dll中。 I'm not sure how well the hashed part of the directory name repeats from one machine to another. 我不确定目录名称的哈希部分从一台计算机到另一台计算机的重复程度。

You cannot see this file with Windows Explorer, you must use the command prompt. 在Windows资源管理器中看不到此文件,必须使用命令提示符。 Go check to see if it there, something went seriously wrong when .NET was installed if it is missing. 去检查它是否存在,如果缺少.NET,则在安装.NET时出现严重问题。 The ".NET Runtime Optimization Service" is the one that gets that job done, make sure you didn't disable it. “ .NET运行时优化服务”是完成该工作的一项,请确保未禁用它。

A standard mistake is running ngen.exe from a command prompt that isn't elevated. 一个标准错误是从未提升的命令提示符下运行ngen.exe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM