I've noticed this for a long time since I've used DevExpress… but never really try to tackle it till now…
The problem is that in a Winforms App… I notice that if I opened a form within the app (say it's an MDI app)… the first time that form will take forever to load. However, if I closed that form and then reopen it again, it would be must faster relative to the first load. This happens for each form that's in the application.
I've tried to initialize each form in the application by doing new… to now avail!
I've tried ngen install myapp.exe … no difference
I've tried… and still no go…
private static void PreLoadDlls()
{
foreach (var asm in AssemblyHelper.GetDevExpressAssemblies()) // Get all devexpress assemblies referenced
{
RunTypeInitializers(Assembly.Load(asm));
}
RunTypeInitializers(Assembly.GetEntryAssembly());
RunTypeInitializers(Assembly.GetExecutingAssembly());
}
static void RunTypeInitializers(Assembly a)
{
Type[] types = a.GetExportedTypes();
for (int i = 0; i < types.Length; i++)
{
RuntimeHelpers.RunClassConstructor(types[i].TypeHandle);
}
}
What is it that is taking so long on the first load?
Thanks
Kim