利用反射调出其他项目的界面

主要针对问题:解决DLL循环调用的矛盾

示例:

     private void buttonInsuranceClaims_Click(object sender, System.EventArgs e)
        {
            try
            {
                Assembly AdvanceAssembly = Assembly.Load("DMS.Insurance.UI");

                Type t = AdvanceAssembly.GetType("DMS.Insurance.UI.InsureMgr.RF_InsuranceClaimsDetailForm");

                object obj = t.InvokeMember(null, 
                    BindingFlags.DeclaredOnly | 
                    BindingFlags.Public | BindingFlags.NonPublic | 
                    BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null);

                t.InvokeMember("m_RepairNo", 
                    BindingFlags.DeclaredOnly | 
                    BindingFlags.Public | BindingFlags.NonPublic | 
                    BindingFlags.Instance | BindingFlags.SetField, null, obj, new Object[] {m_RepairNo});

                t.InvokeMember("m_FrameNo", 
                    BindingFlags.DeclaredOnly | 
                    BindingFlags.Public | BindingFlags.NonPublic | 
                    BindingFlags.Instance | BindingFlags.SetField, null, obj, new Object[] {m_FrameNo});

                t.InvokeMember("InitViewForRepairCard", 
                    BindingFlags.Public | 
                    BindingFlags.Instance | BindingFlags.InvokeMethod, null, obj, null);
            
                t.InvokeMember("ShowDialog", 
                    BindingFlags.Public | 
                    BindingFlags.Instance | BindingFlags.InvokeMethod, null, obj, null);
            }
            catch(System.Exception ex)
            {
                MessageBox.Show("加载理赔定损窗体失败。\n\n错误信息:" + ex.Message,"加载窗体失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        
        }

posted @ 2013-10-22 11:59  沙耶  阅读(327)  评论(0编辑  收藏  举报