c# warning - Mark assemblies with NeutralResourcesLanguageAttribute

柔情痞子 提交于 2019-12-04 16:37:55

问题


I'm getting the following warning: "CA1824 Mark assemblies with NeutralResourcesLanguageAttribute"

According to MSDN, the cause of this is: An assembly contains a ResX-based resource but does not have the System.Resources.NeutralResourcesLanguageAttribute applied to it.

Could anyone please explain what it means? I don't want to define specific culture setting. I want them to be customisable.


回答1:


The NeutralResourcesLanguageAttribute informs the resource manager of the language that was used to display resources which are contained in the main assembly. E.g. if you coded your assembly so that it contains resources which are in English, then include the following line in your AssemblyInfo.cs

[assembly: NeutralResourcesLanguage("en")]

This way, when looking up resources in English, the resource manager will not look for an English culture satellite assembly, but rather just use the resources contained in the main assembly. This is purely a performance optimisation.




回答2:


The NeutralResourcesLanguage attribute tells the resource manager about the language used in your neutral resources (the resources whose filename don't have a culture code suffix, e.g. YourModule.resx). That information can be used during the resource fallback process.



来源:https://stackoverflow.com/questions/4068360/c-sharp-warning-mark-assemblies-with-neutralresourceslanguageattribute

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