zoukankan
html css js c++ java
C#动态加载类
using
System;
using
System.Data;
using
System.Reflection;
using
System.Web;
using
System.Web.UI;
namespace
WebApplication1
{
/**/
///
<summary>
///
Class1 的摘要说明。
///
</summary>
public
class
Servlets:System.Web.UI.Page
{
private
void
Page_Load(
object
sender, System.EventArgs e)
{
//
在此处放置用户代码以初始化页面
Response.Write(InitPage());
AfterLoadPage();
//
string aliasName="test2.Class2";
//
result.AppAssembly = ((ClassItem)item).ClassAssembly;
//
return result;
//
Assembly assem= Assembly.Load(aliasName);
Type[] helloType
=
LoadAssembly(
"
test2
"
);
MethodInfo printMethod
=
helloType[
0
].GetMethod(
"
reback
"
);
Object obj
=
Activator.CreateInstance(helloType[
0
]);
Response.Write(printMethod.Invoke(obj,
null
));
//
Object[] args = new Object[1];
//
args[0] = "From CSharp Late Bound";
//
printMethod.Invoke(obj, args);
//
//
Response.Write(result);
}
public
Type[] LoadAssembly(
string
filename)
{
Type[] functionList
=
new
Type[
10
];
Assembly assembly
=
AppDomain.CurrentDomain.Load(filename);
int
i
=
0
;
foreach
(Type t
in
assembly.GetTypes())
{
functionList[i]
=
t;
i
=
i
+
1
;
}
return
functionList;
}
protected
virtual
void
AfterLoadPage()
{
}
protected
virtual
string
InitPage()
{
return
"
BASE
"
;
}
//
Web 窗体设计器生成的代码
Web 窗体设计器生成的代码
#region
Web 窗体设计器生成的代码
override
protected
void
OnInit(EventArgs e)
{
//
//
CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base
.OnInit(e);
}
/**/
/**/
/**/
///
<summary>
///
设计器支持所需的方法 - 不要使用代码编辑器修改
///
此方法的内容。
///
</summary>
private
void
InitializeComponent()
{
this
.Load
+=
new
System.EventHandler(
this
.Page_Load);
}
#endregion
}
}
查看全文
相关阅读:
凤凰传奇
信息孤岛
别了,中珠
吃苦要趁早
触动——beyond歌词
走出舒适区,迎接挑战
创新永存
信息时代
变色龙时代——创新
Java基本的数据类型
原文地址:https://www.cnblogs.com/chinatefl/p/279656.html
最新文章
(转)libevent介绍及示例
C++游戏开发需要阅读的书籍
新随笔
VC6.0到VS2013全部版本下载地址
emacs配置
Windows下Python,setuptools,pip,virtualenv的安装
新随笔
国外程序员整理的C++资源大全
C++开源代码项目汇总
Hsqldb在Memory-Only模式下方便发布项目
热门文章
Spring Cache 配置及一些问题的解决
密钥 JKS PFK
获取Spring 依赖jar包
weinre调试移动端页面
JS控制页面跳转
mysql dump 等操作
jUnit
Eclipse 下操作Maven项目的问题
JS判断移动端访问设备并解析对应CSS
智慧才是最值得投资的
Copyright © 2011-2022 走看看