预载组件:引用的,未引用,不加载直到需要 [英] Preload assemblies: referenced, unreferenced, not loaded until they are needed

查看:878
本文介绍了预载组件:引用的,未引用,不加载直到需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个闪屏,显示各个组件的加载,显示主力表格前



我做预压:

 大会提出= System.Reflection.Assembly.GetExecutingAssembly(); 
的foreach(的AssemblyName一个在a.GetReferencedAssemblies())
{
的Assembly.Load(的);
}



我有两个问题:



问题1:



一些集会被预载后加载,即使它们没有包含在参考文献:




x.vshost.exe(管理(v4.0.30319)):已加载C:\windows\Microsoft.Net\assembly\\ \\GAC_MSIL\PresentationFramework-SystemData\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemData.dll,跳过加载符号。 。模块进行了优化和调试器选项仅我的代码已启用



x.vshost.exe(管理(v4.0.30319)):已加载C: \windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero.dll,跳过加载符号。模块进行了优化和调试器选项仅我的代码已启用。




我可以通过组件连接到解决这个问题引用,但我不想这样做,因为编译器不会强迫我。



问题2:



我使用Telerik的RadPadeView。在谢胜利页我有一个包含Telerik的WPF甘特(主要应用的WinForm)ElementHost控件。展会的主窗口后,我点击第二个选项卡上看到甘特。 。在这一点上,额外assemby装




x.exe(管理(v4.0.30319)):已加载C:\\ \\windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll,跳过加载符号。 。模块进行了优化和调试器选项仅我的代码已启用



x.exe(管理(v4.0.30319)):已加载C:\ windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll,跳过加载符号。模块进行了优化和调试器选项仅我的代码已启用。




问题是怎么样预加载的所有程序集:




  1. 引用

  2. 未引用(问题1)

  3. 没装需要它们(问题2)


解决方案

的Assembly.Load

是所有你需要从要么已经引用加载大会的类型或文件路径。
见的 MSDN


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)

解决方案

Assembly.Load

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

这篇关于预载组件:引用的,未引用,不加载直到需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆