M milan Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-05 #1 有四个工程组成的C#文件集合,编译后成一个dll, 请问各位高手如何调用此dll,并且调用其dll中写好的类。 谢谢。
活 活化石 Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-05 #3 告诉使用者,命名空间,对外暴露的方法名,属性.你看它的SDK中如何介绍SYSTEM的.
O onlyonekgx Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-05 #5 动态调用: object[] MDIObj; //动态库文件名 private const string ProjectManageDLL="ProjectManage.DLL"; //项目管理 private const string EmployeeDLL="Employee.DLL"; //用户管理 //动态库(DLL,装配件) public Assembly ProjectManage; public Assembly Employee; //动态库类 public object objProjectClass; public object objEmployeeClass; //ProjectManage方法(DELPHI中的导出函数) public MethodInfo ProjectFormCreate; public MethodInfo ConsumerFormCreate; //Employee public MethodInfo EmpManageFormCreate; private void LoadProjectManage() //装载项目管理模块 { if(ProjectManage==null && File.Exists(ProjectManageDLL)) { ProjectManage=Assembly.LoadFrom(ProjectManageDLL); Type[] pt=ProjectManage.GetTypes(); foreach(Type t in pt) //采用循环的原因是直接使用 GetType 没有成功 { if(t.IsClass && !t.IsAbstract && t.Name=="ProjectClass") { objProjectClass=Activator.CreateInstance(t); //创建实例 ProjectFormCreate=t.GetMethod("ProjectFormCreate"); ConsumerFormCreate=t.GetMethod("ConsumerFormCreate"); } } } }
动态调用: object[] MDIObj; //动态库文件名 private const string ProjectManageDLL="ProjectManage.DLL"; //项目管理 private const string EmployeeDLL="Employee.DLL"; //用户管理 //动态库(DLL,装配件) public Assembly ProjectManage; public Assembly Employee; //动态库类 public object objProjectClass; public object objEmployeeClass; //ProjectManage方法(DELPHI中的导出函数) public MethodInfo ProjectFormCreate; public MethodInfo ConsumerFormCreate; //Employee public MethodInfo EmpManageFormCreate; private void LoadProjectManage() //装载项目管理模块 { if(ProjectManage==null && File.Exists(ProjectManageDLL)) { ProjectManage=Assembly.LoadFrom(ProjectManageDLL); Type[] pt=ProjectManage.GetTypes(); foreach(Type t in pt) //采用循环的原因是直接使用 GetType 没有成功 { if(t.IsClass && !t.IsAbstract && t.Name=="ProjectClass") { objProjectClass=Activator.CreateInstance(t); //创建实例 ProjectFormCreate=t.GetMethod("ProjectFormCreate"); ConsumerFormCreate=t.GetMethod("ConsumerFormCreate"); } } } }