动态加载大会和手动强制路径来获得引用的程序集 [英] Dynamically Load Assembly and manually force path to get referenced assemblies

查看:85
本文介绍了动态加载大会和手动强制路径来获得引用的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用反射加载的程序集在C#中:

I am loading an assembly in C# using reflection:

Assembly = Assembly.Load([assembly_bytestream]);

该组件加载引用另外两个组件。据我了解反射将加载主组件,然后搜索GAC为引用的程序集,如果它不能找到它,然后你可以incorparate的AssemblyResolve事件:

The assembly being loaded references another two assemblies. To my understanding reflection will load the main assembly and then search the GAC for the referenced assemblies, if it cannot find it there, you can then incorparate an assemblyResolve event:

AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
  if (args.Name.IndexOf([refAsm]) > -1)
  {
    Assembly shdocvw = Assembly.LoadFrom([dllPath]);
  }
}



的事情是,我不想先查看海关总署我要强制反射从我定义了一个特定的路径加载引用程序集。如何做到这一点任何想法?

The thing is, I dont want to first look in the GAC I want to force reflection to load the reference assemblies from a specific path I define. Any ideas on how to do this?

推荐答案

您可以自己加载在需要它们的人之前加载依赖程序集。

You could load the dependent assemblies yourself before loading the one that requires them.

这篇关于动态加载大会和手动强制路径来获得引用的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆