use Assembly to call a method
2008-03-08 12:55:55 来源:WEB开发网核心提示: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
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;
}
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;
}
- ››user-agent查询方法
- ››TOscilloscope 仿Windows任务管理器CPU使用记录组...
- ››tomcat不支持TCP/IP6协议
- ››tomcat 下的 url 大小写问题
- ››tomcat6.0.28 内存溢出PermGen Space
- ››Tomcat 系统架构与设计模式,第 2 部分: 设计模式...
- ››Tomcat 系统架构与设计模式,第 1 部分: 工作原理...
- ››TOMCAT和IIS整合
- ››userinit.exe出现异常之解决方案
- ››Tomcat性能调优方案
- ››Tomcat6 下 MySQL 5.1 数据源配制
- ››Tomcat启动分析server.xml
更多精彩
赞助商链接