没有合适的资源?快使用搜索试试~ 我知道了~
C#关于反射加载的问题,需要的朋友可以参考下。
资源推荐
资源详情
资源评论
C#关于反射加载的问题关于反射加载的问题
C#关于反射加载的问题,需要的朋友可以参考下。
三个程序集:
主程序集:BaseApp.exe
接口程序集:IBaseApplication
插件程序集:TestAttri
=======================================================================================
在接口程序中:
接口:IApp
属性定义:ModuleAttribute
复制代码 代码如下:
public interface IApp : IMothed
{
void ParentForm(IApp frm);
}
namespace IBaseApplication.Attributes
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Field | AttributeTargets.Method |
AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
public class ModuleAttribute : Attribute
{
public string IdName { get; set; }
public string ModuleName { get; set; }
public Type ModuleType { get; set; }
//public string AsmName { get; set; }
//public string ClassName { get; set; }
public string Description { get; set; }
}
}
在插件程序集中:
在该插件程序集中的AssemblyInfo类中标识如下
复制代码 代码如下:
[assembly: IBaseApplication.Attributes.Module(ModuleType = typeof(UserControl1), IdName = "be4d9a5b-0455-4e9d-a255-
25122b80bef1-UserControl1", ModuleName = "UserControl1", Description = "")]
[assembly: IBaseApplication.Attributes.Module(ModuleType = typeof(UserControl2), IdName = "be4d9a5b-0455-4e9d-a255-
25122b80bef1-UserControl2", ModuleName = "UserControl2", Description = "")]
有两个模块分别是以下
复制代码 代码如下:
namespace TestAttri
{
public partial class UserControl1 : UserControl, IApp
{
……
}
}
namespace TestAttri
{
public partial class UserControl2 : UserControl, IApp
{
……
}
}
=================================================================================================
在主程序集中:
将插件放至到:Application.StartupPath + "\Plus"
引用了接口程序集“IBaseApplication”
复制代码 代码如下:
/// <summary>
/// 获取插件文件名称
/// </summary>
资源评论
weixin_38582909
- 粉丝: 5
- 资源: 975
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功