本文介绍了是否可以将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部署一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!