internal sealed class LubanAddin : Bentley.MicroStation.AddIn { private LubanAddin(System.IntPtr mdlDesc) : base(mdlDesc) { } protected override int Run(string[] commandLine) { ExecuteMethod("Initialize"); return 0; } public void ExecuteMethod(String strMethod) { try { if (null == m_Assembly) { string strPath = ""; if (CommonFunction.GetLbTransPath(ref strPath)) // 加载Bentley插件 m_Assembly = Assembly.LoadFrom(strPath + "\\" + "LBExternalApplication.dll"); } if (null == m_Assembly) return; Type[] type = m_Assembly.GetTypes(); foreach (Type t in type) { // 查找要调用的命名空间及类 if (t.Namespace == "LBFileUpdate" && t.Name == "LBAppEntry") { // 查找要调用的方法并进行调用 MethodInfo m = t.GetMethod(strMethod); if (m != null) { object reflectTest = Activator.CreateInstance(t); m.Invoke(reflectTest, new object[] { }); break; } } } } catch (System.Exception ex) { } } // 当前程序集变量 private Assembly m_Assembly = null; }
能否将添加按钮的代码放在另一个dll中,不放在LubanAddin.dll里?