码迷,mamicode.com
首页 > Windows程序 > 详细

C#加载dll 创建类对象

时间:2015-12-21 10:48:26      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:

//加载dll 创建类对象
string
sqlightAssembly = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "system.data.sqlite.dll"); Assembly lib = Assembly.LoadFrom(sqlightAssembly); foreach (Type t in lib.GetExportedTypes()) { if(t.FullName == "System.Data.SQLite.SQLiteFactory") return (DbProviderFactory)Activator.CreateInstance(t); }

 

//获取CPU类型
private
ProcessorType GetProcessorArch() { using (System.Management.ManagementClass processors = new System.Management.ManagementClass("Win32_Processor")) { foreach (System.Management.ManagementObject processor in processors.GetInstances()) { int AddressWidth = int.Parse(processor["AddressWidth"].ToString()); int Architecture = int.Parse(processor["Architecture"].ToString()); //See Win32_Processor Class for details if (AddressWidth == 32) return ProcessorType.x86; if (AddressWidth == 64 && Architecture == 9) return ProcessorType.x64; if (AddressWidth == 64 && Architecture == 6) return ProcessorType.IPF; } } throw new NotSupportedException(); }

 

C#加载dll 创建类对象

标签:

原文地址:http://www.cnblogs.com/profession/p/5062559.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!