当Assembly在CurrentDomain中时,为什么调用AssemblyResolve? [英] Why is AssemblyResolve called when Assembly is in CurrentDomain?

查看:477
本文介绍了当Assembly在CurrentDomain中时,为什么调用AssemblyResolve?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这样的情况,对于已经使用 Assembly.Load加载到当前域的程序集,调用 AppDomain.CurrentDomain.AssemblyResolve (myAssemblyMemStream.ToArray())

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

为什么?

I需要执行以下操作才能使其正常工作。

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


推荐答案

加载上下文 http://blogs.msdn.com/b/suzcook/archive/2003 /05/29/57143.aspx 。加载byte []不会导致其他加载上下文中的程序集能够看到它。这是一项安全功能。

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.

这篇关于当Assembly在CurrentDomain中时,为什么调用AssemblyResolve?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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