Why is AssemblyResolve called when Assembly is in CurrentDomain?

ε祈祈猫儿з 提交于 2019-12-11 01:41:33

问题


I have a situation where AppDomain.CurrentDomain.AssemblyResolve is called for an assembly that has already been loaded into the current domain using Assembly.Load(myAssemblyMemStream.ToArray()).

Why is that?

I need to do the following to get it to work. How does this differ from what .NET does automatically?

Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    return AppDomain.CurrentDomain
                    .GetAssemblies()
                    .First(x => x.FullName == args.Name);
}

回答1:


Load contexts http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57143.aspx. Loading the byte[] doesn't cause assemblies in other load contexts to be able to see it. It is a security feature.



来源:https://stackoverflow.com/questions/13305301/why-is-assemblyresolve-called-when-assembly-is-in-currentdomain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!