是否可以将NGen与ClickOnce部署一起使用?

编程入门 行业动态 更新时间:2024-10-10 08:23:40
本文介绍了是否可以将NGen与ClickOnce部署一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以将NGen与ClickOnce部署一起使用?

Is it possible to use NGen with ClickOnce deployment?

推荐答案

实际上您可以使用NGEN和clickone,但是您要使用在clickonce安装完成后需要运行NGEN,因为NGEN是.NET安装的一部分(对于3.5,您应该参考2.0安装)。

Actually you can use NGEN and clickone, but you are going to need to run the NGEN after the clickonce installation has happened, since NGEN is part of the .NET installation (for 3.5 you should refer to the 2.0 installation).

此处是一个例子,我认为它足够通用,您无需更改代码或对其进行很少更改即可使用它(除了调用表单):

Here is an example, I think it is generic enough for you to use it without changing or doing very little changes to the code (except for the call to your form):

static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun) { string appPath = Application.StartupPath; string winPath = Environment.GetEnvironmentVariable("WINDIR"); Process proc = new Process(); System.IO.Directory.SetCurrentDirectory(appPath); proc.EnableRaisingEvents = false; proc.StartInfo.CreateNoWindow = false; proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.FileName = winPath + @"\Microsoft.NET\Framework\v2.0.50727\ngen.exe"; proc.StartInfo.Arguments = "uninstall " + Application.ProductName + " /nologo /silent"; proc.Start(); proc.WaitForExit(); proc.StartInfo.FileName = winPath + @"\Microsoft.NET\Framework\v2.0.50727\ngen.exe"; proc.StartInfo.Arguments = "install " + Application.ProductName + " /nologo /silent"; proc.Start(); proc.WaitForExit(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }

更多推荐

是否可以将NGen与ClickOnce部署一起使用?

本文发布于:2023-11-17 10:36:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609757.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NGen   ClickOnce

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!