AppDomain.AssemblyResolve资源文件的事件 [英] AppDomain.AssemblyResolve Event for resources files

查看:126
本文介绍了AppDomain.AssemblyResolve资源文件的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在实施 AppDomain.AssemblyResolve http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx [ ^ ])eventhandler 。



一切正常,我只需返回汇编,否则只需 null 就像文档建议的那样。每次.NET尝试自行解析程序集之前,都会调用事件



通常 AssemblyName.FullName 提供 ResolveEventArgs 这很容易上班因为每个汇编都有一个 AssemblyName 。除名称外, ResolveEventArgs 有时也会在程序集中提供.resources文件。



文档中提到了此行为:

从.NET Framework 4开始,将为所有程序集(包括资源程序集)引发ResolveEventHandler事件。 / b>



不是问题,但是在请求.resources文件时应该返回什么?只是汇编,其中包含请求的.resources文件?

在我目前的基础设施中添加并不难,我只是想知道这是不是正确的事情去做。现在我只返回null。



提前谢谢

Hello,

I'm implementing an AppDomain.AssemblyResolve (http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx[^]) eventhandler.

Everything works fine, I just return the Assembly when I can, otherwise just null like the documentation suggests. The event is called every time before .NET attempts to resolve the Assembly by itself.

Normally a AssemblyName.FullName is provided with the ResolveEventArgs This is easy to work with since each Assembly has an AssemblyName. Apart from names, the ResolveEventArgs sometimes also give a .resources file within an Assembly.

This behaviour is mentioned in the documentation:
Beginning with the .NET Framework 4, the ResolveEventHandler event is raised for all assemblies, including resource assemblies.

Not a problem, but what should I return when a .resources file is requested? Just the Assembly which contains the requested .resources file?
In my current infrastructure it's not hard to add, I just wonder if it's the right thing to do. Right now I just return null.

Thanks in advance

推荐答案

如你所说,它不是实际上是关于.resources文件,它是关于某个程序集中的嵌入式资源,称为附属程序集。



As you mentioned, it is not actually about .resources files, it is about embedded resources within a certain assembly, known as satellite assemblies.

Quote:

从.NET Framework 4开始,为卫星程序集引发AssemblyResolve事件。

Beginning with the .NET Framework 4, the AssemblyResolve event is raised for satellite assemblies.



来源:http://msdn.microsoft.com/en-us/library/ff527268.aspx [ ^ ]




Source: http://msdn.microsoft.com/en-us/library/ff527268.aspx[^]

Quote:

卫星装配



包含特定于给定语言的资源的.NET Framework程序集。使用附属程序集,您可以将不同语言的资源放在不同的程序集中,只有当用户选择以该语言查看应用程序时才能将正确的程序集加载到内存中。

satellite assembly

A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user elects to view the application in that language.



来源: http://msdn.microsoft.com/en- GB / library / c83eyewf%28v = vs.80%29.aspx [ ^ ]



你需要退货包含资源的程序集,因为这个简短的句子告诉你:


Source: http://msdn.microsoft.com/en-GB/library/c83eyewf%28v=vs.80%29.aspx[^]

You will need to return the assembly containing the resource, as this short sentence tells you:

Quote:

ResolveEventHandler for this事件可以尝试找到包含资源的程序集并将其返回。

The ResolveEventHandler for this event can attempt to locate the assembly containing the resource and return it.



来源: http://msdn.microsoft.com/en-us/library/syst em.appdomain.resourceresolve.aspx [ ^ ]



希望这有帮助。


Source: http://msdn.microsoft.com/en-us/library/system.appdomain.resourceresolve.aspx[^]

Hopes this help.


这篇关于AppDomain.AssemblyResolve资源文件的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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