

Specify a path to the file that stores your executable’s hash. Var assemblyLocation = Assembly.GetEntryAssembly().Location To only run Ngen.exe for the first startup, calculate a hash for your executable file and check this hash during subsequent startups: If you distribute your application as Click Once or an archive (and don’t have an installer), you can call Ngen.exe from code during application startup.
#Startup time install
You’ll need to execute the following line during the installation process and Ngen.exe will automatically process all assemblies associated with your project: C:\Windows\Microsoft.NET\Framework\v9\ngen.exe install C:\MyApp.exe The best way to run Ngen on a user’s machine is to incorporate Ngen.exe within your application installer. You can run it on your machine to test performance, but to optimize cold start for an end user, you need to use Ngen.exe on the user machine. It’s important to note that Ngen.exe should be used on the machine where your application will be used. You can use Ngen.exe to generate native image libraries that already contain native code. Translation from MSIL to machine code begins at startup - a process that may require significant time.

This code needs to be translated to machine code before executing the application. NET Framework projects produce assemblies with Microsoft Intermediate Language (MSIL) code. NET Framework app (.NET/.NET Core projects don’t support Ngen). Native Image Generator (Ngen.exe) is the first tool you should consider when optimizing startup for a.

The 3 techniques listed below apply to all WPF apps, regardless of components used: This post will document 9 strategies to improve cold start performance for your WPF app.
