ror体育

文章索引 聚合服务页

工 具 文 档

您现在的位置:  >> 站长教程 >> 编程技术 >> .NET >> 正文
站内文章搜索:

use Assembly to call a method

作者:佚名    文章来源:站长之家    点击数:4876    更新时间:2009/1/6

When using objectFactory,u may want to call a static method,but would not like to write a mass of interfaces to *Show* the method.Here,it's a way.

Code:
using System.Reflection;

try
   {
    Assembly asm =Assembly.Load("FC.Shared.Common");
    Type t = asm.GetType("FC.Shared.Common.CMessage");
    MethodInfo minfo=t.GetMethod("Send");
    Object obj = Activator.CreateInstance(t);
   //Object obj=asm.CreateInstance("FC.Shared.Common.CMessage");
    minfo.Invoke(obj,new string []{"IMMsgOut","Sender","Recipient","hello","Body","BizBody"});
    
   }
   catch(Exception e)
   {
    MessageBox.Show(e.InnerException.Message);
    throw e.InnerException;
   }


文章录入:文章录入:zhangmao    责任编辑:zm 
ror体育相关的文章:
没有ror体育相关的文章