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
}
}
查看全文
相关阅读:
Codeforces 912E
Codeforces 912D
洛谷P4980 【模板】Polya定理
51nod1222最小公倍数计数
15 Puzzle LightOJ
loj2734「JOISC 2016 Day 2」女装大佬 || 洛谷P3615 如厕计划
Jongmah Codeforces
洛谷P4238【模板】多项式求逆
洛谷P4721 【模板】分治 FFT
FFT,NTT
原文地址:https://www.cnblogs.com/chinatefl/p/279656.html
最新文章
算法笔记--笛卡尔树模板
HDU 6184 Counting Stars
BZOJ 4488: [Jsoi2015]最大公约数
HDU 6568 Math
Codeforces 348 D
2019暑期多校
LightOJ
AtCoder Beginner Contest 133 F Colorful Tree
Codeforces 1179 D
2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15) C
热门文章
2018-2019 XIX Open Cup, Grand Prix of Korea B
Codeforces 1187 F
Codeforces 939E
Codeforces 939C
Codeforces 939D
Codeforces 919C
Codeforces 918D/917B
Codeforces 918C/917A
Codeforces Hello 2018 C
AtCoder ABC 085C/D
Copyright © 2011-2022 走看看