Adding references dynamically in .NET

2019-04-11 01:18发布

I have two dll's (sqlite) , one dll is a 64 bit and other 32 bit dll. Is it possible to add reference dynamically based on processor architecture? P/Invoke is my last option. Any help would be appreciated!!

Sample Code:

string pathToDll = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\x64\\System.Data.SQLite.dll";
Assembly assembly = Assembly.LoadFrom(pathToDll);
AppDomain.CurrentDomain.Load(assembly.GetName());

标签: c# .net dll
1条回答
Animai°情兽
2楼-- · 2019-04-11 02:04

Yes, you can load assembly from a file

 Assembly.LoadFrom("MyAssembly.dll");

from .net4 you may use Is64BitOperatingSystem Environment property. Otherwise check IntPtr.Size which changes according to running architecture

Cannot encrypt / decrypt SQLite database in .NET4

查看更多
登录 后发表回答