111,126
社区成员
发帖
与我相关
我的任务
分享
[NonSerialized]
Type moduleType;
[XmlIgnore]
[Browsable(false)]
public Type ModuleType
{
get
{
if (moduleType == null)
{
try
{
moduleType = Assembly.GetType(窗体名, false,true);
if (moduleType == null)
{
Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly var in ass)
{
moduleType = var.GetType(窗体名, false);
if (moduleType != null)
break;
}
}
}
catch
{
}
}
return moduleType;
}
set { moduleType = value; }
}
[NonSerialized]
Assembly assembly;
[XmlIgnore]
[Browsable(false)]
public Assembly Assembly
{
get
{
if (assembly == null)
{
try
{
assembly = AppDomain.CurrentDomain.Load(程序集);
}
catch
{
}
}
return assembly;
}
set { assembly = value; }
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace myReflection
{
class Program
{
static void Main(string[] args)
{
Master ma = new Master();
Type tp = ma.GetType();
MethodInfo [] MI = tp.GetMethods();
foreach (MethodInfo mm in MI)
{
Console.WriteLine(mm.Name);
}
}
}
class Student
{
private string stuName;
public string StuName
{
get { return stuName; }
set { stuName = value; }
}
private int stuAge;
public int StuAge
{
get { return stuAge; }
set { stuAge = value; }
}
public void study()
{
Console.WriteLine('学习!');
}
}
class Master:Student
{
public void Say()
{
Console.WriteLine('硕士........');
}
}
}
try
{
Assembly a = Assembly.LoadFile(Application.StartupPath + "\\MultipleUpDown.exe");
Type[] types = a.GetTypes();
Form _Form = null;
foreach(Type type in types)
{
try
{
Form _Form = a.CreateInstance(type.ToString()) as Form;
if(_Form.Name == "MainForm")
{
break;
}
}
catch
{
}
}
//执行带参数的方法
MethodInfo miParas = type.GetMethod("NewTaskWithoutDialog");
miParas.Invoke(_Form, new object[] { TableInfo, UpDownType.DOWNLOAD, false, false, "", "升级后自动下载" });
}
catch
{
}