您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200602
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

use Assembly to call a method

crabo

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;
   }