且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在.NET中动态添加引用

更新时间:2023-12-06 10:06:52

是的,您可以从文件加载程序集



  Assembly.LoadFrom(MyAssembly.dll);可以使用.net4中的

,您可以使用Is64BitOperatingSystem Environment属性。否则检查IntPtr.Size哪些更改根据运行的架构



无法在.NET4中加密/解密SQLite数据库


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());

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