根据装配动态加载表格

编程入门 行业动态 更新时间:2024-10-24 06:29:49
本文介绍了根据装配动态加载表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有办法使用接口来加载在其他项目程序集(.dll文件)中编译的表单?有人有一些代码示例. 我目前正在使用Mdi childs 子项[SA]和功能区来开发Windows应用程序,我需要根据接口和反射在文件夹上找到的程序集来动态加载表单. 如果有人有一些代码/示例...,请:/

Hi, Is there any way to load forms compiled in other project assemblies(.dll files) using interfaces ? Has anyone some code example. I am currently developing a Windows Application using Mdi childs children [SA] and ribbons and I need to dynamicaly load forms depending on assemblies found on folder using Interfaces and reflection. If anyone has some code / example... Please :/

推荐答案

当然可以.您甚至可以在运行时编译某些项目并添加已编译的程序集.没错,可以使用接口来完成. 实际上,在其他程序集中编译"尚不清楚.您可以在定义窗体和/或其他零部件的地方静态引用装配,然后在装配中使用它们.这很简单;您几乎不需要任何代码示例.动态加载程序集比较困难,但不是问题.请参见下面. 我的建议是:永远不要使用MDI;强烈建议不要使用此样式(首先,我的Microsoft引入了MDI),另请参见: 在WPF中使用MDI窗口的问题 [ ^ ], 提供错误的MDIContainer [ ^ ]. 现在,关于可以用作插件的动态加载的程序集.请在我过去的回答中查看我的插件功能示意图: 创建使用可重载插件的WPF应用程序... [ ^ ], AppDomain拒绝加载程序集 [ ^ ]. 不要以为这很困难.您可以忽略与可重新加载的插件和Application Domain相关的所有内容.不过要看情况.如果您确实要卸载插件,则将需要所有这些.实施起来并不难,但在其第一阶段将需要大量的精力.首先,最好在高度简化的模型上进行原型制作. 这是针对MDI的另一个链接: en.wikipedia/wiki/Multiple_document_interface#Disadvantages [ ^ ]. 这是针对表单的选项卡式UI的最简单演示: 带标签的MDI子表单 [ ^ ]. 查看更多内容(一些用于WPF,一些用于窗体,这些技术非常接近): 多标签Web浏览器 [ ^ ], 在WPF中标记的MDI [ ^ ], WPF C#功能区控制库 [ ^ ](复杂), 类似于FireFox的标签控件 [ ^ ]. 您可以通过搜索CodeProject文章或Google来找到更多信息.如果我是你,我只会拿一个TabControl并从头开始实现它.首先将主菜单和状态栏添加到一个空的主窗体中.添加一个TabConrol,使其为Dock = DockStyle.Fill.这就是所有框架. 在设计时和/或运行时,您作为子窗体拥有的内容将转到选项卡"页面(它们的内容将会).我告诉你,比MDI孩子要容易得多.提供内容控件的插件也是如此.
—SA
Yes of course. You can even compile some project during run-time and add compiled assemblies. And right, it can be done using interfaces. Actually, "compiled in other assemblies" is not clear. You can statically reference the assemblies where you define forms and/or other components and than use it in your assembly. This is straightforward; you hardly need any code samples. Dynamically loading assemblies is more difficult but not a problem. Please see below. My advice would be: never use MDI; this style is highly discourages (first of all, my Microsoft where MDI was introduced), see also: Question on using MDI windows in WPF[^], MDIContainer giving error[^]. Now, about dynamically loaded assemblies which you can use as plug-ins. Please see my sketch of plug-in functionality in my past answers: Create WPF Application that uses Reloadable Plugins...[^], AppDomain refuses to load an assembly[^]. Don''t think it''s very difficult. You can ignore everything related to reloadable plug-ins and Application Domain. It depends though. It you really want to unload your plug-ins, you will need all that. It''s not too hard to implement but will need considerable effort in the first stage of it. Better do prototyping on highly simplified model first. Here is one more link against MDI: en.wikipedia/wiki/Multiple_document_interface#Disadvantages[^]. This is the simplest demonstration of Tabbed UI for forms: Tabbed MDI Child Forms[^]. See some more (some for WPF, some for Forms, the techniques are very close): Multi Tab WebBrowser[^], Tabbed MDI in WPF[^], WPF C# Ribbon Control Library[^] (complicated), FireFox-like Tab Control[^]. You will be able to find a lot more is you search CodeProject articles or Google. If I were you I would just take a TabControl and implemented it from scratch. Add main menu and status bar to an empty main form first. Add a TabConrol, make its Dock = DockStyle.Fill. That''s all the framework. What you had as child Forms will go to the Tab pages (their contents will), during design time and/or run time. Much easier then MDI children, I tell you. Same thing about your plug-ins providing content controls.
—SA

您可能还想看看反射. 此 [ ^ ]出色的文章介绍了当您希望将表单加载到未引用的程序集中时的情况. You might also want to look at reflection. This[^] excellent article describes this when you want a form to be loaded in unreferenced assemblies.

更多推荐

根据装配动态加载表格

本文发布于:2023-11-13 10:37:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584150.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表格   加载   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!