use Assembly to call a method

haige处女座

haige处女座

2016-01-29 13:08

use Assembly to call a method,use Assembly to call a method

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; }
展开更多 50%)
分享

猜你喜欢

use Assembly to call a method

电脑网络
use Assembly to call a method

In Javascript Class, how to call the prototype method.(three method)

Web开发
In Javascript Class, how to call the prototype method.(three method)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Edit Method

电脑网络
Edit Method

AddNew Method Example

电脑网络
AddNew Method Example

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

什么是配件(assembly)?

电脑网络
什么是配件(assembly)?

Edit Method Example

电脑网络
Edit Method Example

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

自定义控件(可以动态加载用户控件)

自定义控件(可以动态加载用户控件)

PHP 编码规范-代码范例

PHP 编码规范-代码范例
下拉加载更多内容 ↓