是否可以预先生成NGen映像,以便客户不必这样做? [英] Is it possible to pre-generate NGen images so customers don't have to?

查看:91
本文介绍了是否可以预先生成NGen映像,以便客户不必这样做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过ClickOnce分发的我们的应用平均需要花费 10.8秒才能启动。在.exe(ClickOnce将其安装到的目录中)上运行 ngen 后,它平均启动时间为 6.4秒。显然这是一个巨大的提速( 40%),我想尽可能地利用ngen-ification。

Our app, distributed via ClickOnce, takes 10.8 seconds on average to start up. After running ngen on the .exe (in the directory that ClickOnce installed it into), it starts up in 6.4 seconds on average. This is obviously a huge speedup (40%) and I would like to make use of ngen-ification if possible.

Ron对< a href = https://stackoverflow.com/questions/443955>是否可以将NGen与ClickOnce部署一起使用?显示了如何在客户的计算机上完成此操作,假设我猜他正在运行 Windows XP ,因为它希望在我的 Windows 7 框中具有管理员权限,所以这似乎不是通用解决方案。

Ron's answer to Is it possible to use NGen with ClickOnce deployment? shows how it can be done on the customer's machine, assuming I guess he runs Windows XP, as it wants Administrator rights on my Windows 7 box, so that does not seem like a generic solution.

此外,ngen在我的盒子上需要 40秒来编译属于该应用程序的所有程序集。

Furthermore, ngen takes 40 seconds on my box to compile all assemblies belonging to that app.

因此,理想情况下,我想在构建过程中为所有(主要)架构预生成我们的应用,这样就可以将其交付给客户,而无需用户接受可以按以下方式执行管理员?弹出窗口,然后等待40秒。

So ideally, I'd like to pre-ngen our app for all (major) architectures as part of the build process, so it could be shipped to the customer without the user having to accept an "ok to execute as admin?" popup and then wait 40 seconds.

有可能吗?

推荐答案

如果没有Windows 7上的管理访问权限,您将无法执行此操作。

You can't do this without administrative access on Windows 7.

问题不是本机映像的实际ngen生成,而是安装到本机映像缓存中(C:\windows\assembly\nativeImages_v#xxxxxxxxx)需要管理权限。因此,即使您找到了一种为所有目标体系结构预生成本机映像的方法,也将无法将其放入适当的位置,以便运行时考虑使用它们。

The problem isn't the actual ngen generation of the native image but the installation into the native image cache (C:\windows\assembly\nativeImages_v#xxxxxxxxx) that requires administrative permissions. So even if you found a way to pre-generate the native images for all the target architectures you would not be able to get them into the appropriate location for the runtime to consider using them.

您不能只将它们与常规二进制文件并排放置,因为这样将无法正确地管理它们-当确定某些二进制文件时,您会遇到麻烦进行安全策略更改,应用.net框架更新或对引用的程序集进行其他更改,这些更改会使本机映像无效,并且需要运行 ngen update命令。微软目前似乎不支持在ClickOnce部署中使用ngen的用例。

You can't just place them side-by-side with your regular binaries because then they wouldn't be managed properly--you'd get into trouble when certain security policy changes are made, .net framework updates are applied or other changes are made to referenced assemblies that invalidate the native images and would require an "ngen update" command to be run. Microsoft just doesn't appear to support the use-case of ngen with ClickOnce deployment at this time.

这篇关于是否可以预先生成NGen映像,以便客户不必这样做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆