我有两个dll(xNet.dll
和ag.dll
),我想在我的项目中使用它。
我将它们添加到资源中,表示构建操作是嵌入式资源。 接下来我有这样的代码来加载第一个dll:
public Form1()
{
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;
InitializeComponent();
}
private static Assembly AssemblyResolve(object sender, ResolveEventArgs args)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string assemblyName = args.Name.Split(',')[0];
using (Stream stream = assembly.GetManifestResourceStream("Yandex.dll.xNet.dll"))
{
if (stream == null)
return null;
byte[] rawAssembly = new byte[stream.Length];
stream.Read(rawAssembly, 0, (int)stream.Length);
return Assembly.Load(rawAssembly);
}
}
如何加载第二个dll?
答案 0 :(得分:-1)
是
using xNet;
using ag;
太难了?