c# – 预加载程序集:引用,未引用,在需要之前不加载

我想在显示主窗体之前创建一个启动屏幕,显示单个装配的加载.

我正在做的预加载:

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

我有两个问题:

问题1:

某些程序集在预加载后加载,即使它们未包含在引用中:

‘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.

我可以通过将程序集连接到引用来解决这个问题,但我不想这样做,因为编译器不强迫我.

问题2:

我正在使用telerik RadPadeView.在secound页面上,我有一个ElementHost控件,它包含来自Telerik的WPF Gantt(主应用程序是WinForm).在显示主窗口后,我点击第二个选项卡查看甘特图.在这一点上,加载了额外的组合.

‘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.

问题是,如何预加载所有程序集:

>参考
>未引用(问题1)
>在需要之前不加载(问题2)

解决方法

Assembly.Load

您是否需要从已引用类型或文件路径加载程序集.
MSDN

相关文章

1:最直白的循环遍历方法,可以分为遍历key--value键值对以及...
private void ClearTextBox(){ foreach (var control in pnl...
原文叫看《墨攻》理解IOC概念 2006年多部贺岁大片以让人应接...
右击文件夹->安全选项卡->添加->高级-...