NGen能否与ClickOnce部署一起使用?
使用ClickOnce部署是否可以使用NGen?
原标题:
最佳回答
实际上你可以使用NGEN和clickone,但你需要在clickonce安装完成后运行NGEN,因为NGEN是.NET安装的一部分(对于3.5,你应该参考2.0安装)。
这里有一个例子,我认为它足够通用,可以在不更改或仅作极小修改代码(除调用表格之外)的情况下使用:
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.NETFrameworkv2.0.50727
gen.exe";
proc.StartInfo.Arguments = "uninstall " + Application.ProductName + " /nologo /silent";
proc.Start();
proc.WaitForExit();
proc.StartInfo.FileName = winPath + @"Microsoft.NETFrameworkv2.0.50727
gen.exe";
proc.StartInfo.Arguments = "install " + Application.ProductName + " /nologo /silent";
proc.Start();
proc.WaitForExit();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
问题回答
不可以。请查看http://social.msdn.microsoft.com/Forums/en-US/clr/thread/a41b62c5-bdee-4bd5-9811-15a35c4a4add/。你需要为此创建一个常规安装程序文件。
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding