C# dll 로드 클래스 객체 만들기

2456 단어
//  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(); }

좋은 웹페이지 즐겨찾기