c#动态加载dll中的类
2008-06-16 10:36
519 查看
public class SchemaAssmbly
{
private string assmblyFile = "";
private string objectType = "";
public object realObject = null;
public SchemaAssmbly(string assmblyFile, string objectType)
{
this.assmblyFile = assmblyFile;
this.objectType = objectType;
}
public bool CreateRealObject()
{
if (realObject == null)
{
try
{
if (System.IO.File.Exists(this.assmblyFile))
{
System.Reflection.Assembly assmbly = System.Reflection.Assembly.LoadFile(assmblyFile);
if (assmbly != null)
{
object theObject = assmbly.CreateInstance(objectType, true);
if (theObject != null)
{
realObject = theObject;
return true;
}
}
}
return false;
}
catch (Exception)
{
return false;
}
}
return true;
}
}
{
private string assmblyFile = "";
private string objectType = "";
public object realObject = null;
public SchemaAssmbly(string assmblyFile, string objectType)
{
this.assmblyFile = assmblyFile;
this.objectType = objectType;
}
public bool CreateRealObject()
{
if (realObject == null)
{
try
{
if (System.IO.File.Exists(this.assmblyFile))
{
System.Reflection.Assembly assmbly = System.Reflection.Assembly.LoadFile(assmblyFile);
if (assmbly != null)
{
object theObject = assmbly.CreateInstance(objectType, true);
if (theObject != null)
{
realObject = theObject;
return true;
}
}
}
return false;
}
catch (Exception)
{
return false;
}
}
return true;
}
}
相关文章推荐
- C#中动态加载和卸载DLL
- C#动态加载卸载DLL
- C#通过反射实现动态加载DLL
- C# 实现动态加载DLL插件 及HRESULT:0x80131047处理
- C#中动态加载和卸载DLL
- C#中使用反射来动态加载和卸载DLL
- c# 动态加载dll文件,并实现调用其中的方法
- c#实现动态加载Dll
- C# 动态加载卸载 DLL
- C#实现反射调用动态加载的DLL文件中的方法
- C#中动态加载和卸载DLL
- C# 利用反射动态加载dll
- 转载:C#动态加载DLL
- C#.Net 如何动态加载与卸载程序集(.dll或者.exe)0-------通过应用程序域AppDomain加载和卸载程序集
- C#动态加载DLL
- C#中动态加载和卸载DLL
- C#实现反射调用动态加载的DLL文件中的方法
- C#读取配置文件详解 完全自定义实现动态加载dll
- C#中动态加载和卸载DLL
- C#实现反射调用动态加载的DLL文件中的方法