在.NET中动态添加引用 [英] Adding references dynamically in .NET
本文介绍了在.NET中动态添加引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例代码:
string pathToDll = Path.GetDirectoryName(Assembly.GetExecutingAssembly()。Location)+\\x64\\\System.Data.SQLite.dll;
Assembly assembly = Assembly.LoadFrom(pathToDll);
AppDomain.CurrentDomain.Load(assembly.GetName());
解决方案
是的,您可以从文件加载程序集
Assembly.LoadFrom(MyAssembly.dll);可以使用.net4中的
,您可以使用Is64BitOperatingSystem Environment属性。否则检查IntPtr.Size哪些更改根据运行的架构
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
这篇关于在.NET中动态添加引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文