Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preload assemblies: referenced, unreferenced, not loaded until they are needed

I would like to create a splash screen that shows loading of individual assembly, before showing the main form.

I am doing preload by:

Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
foreach (AssemblyName an in a.GetReferencedAssemblies())
{
    Assembly.Load(an);
}

I have two problems:

Problem 1:

Some assembly are loaded after the preload, even they are not included in the references:

'x.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemData\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemData.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'x.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

I can get around this problem by connecting the assembly to the reference but I do not want to do that since the compiler does not force me.

Problem 2:

I am using telerik RadPadeView. On secound page i have ElementHost control that contain WPF Gantt from Telerik (Main application is WinForm) . After the show the main window, I click on the second tab to see the gantt. And at this point, additional assemby loaded.

'x.exe' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'x.exe' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

The question is, how to preload all assemblies:

  1. Referenced
  2. Unreferenced (Problem 1)
  3. Not loaded until they are needed (Problem 2)
like image 758
Dominik Avatar asked Sep 26 '13 08:09

Dominik


1 Answers

Assembly.Load

Is all you need to load assemblys from either already references types or by filepath. See the MSDN

like image 129
Sievajet Avatar answered Sep 18 '22 17:09

Sievajet