在 C# 类项目中,AssemblyCulture 有何用途?

发布于 2024-12-04 11:26:53 字数 290 浏览 0 评论 0原文

在 C# 类项目中,有一个名为 AssemblyInfo.cs 的属性文件。该文件中包含一系列程序集属性,包括 AssemblyTitleAssemblyDescription 等,用于描述有关已编译项目的某些详细信息。其中之一是AssemblyCulture

我明白其他的用途,但是AssemblyCulture用来描述什么?语言?货币?两者都有一点?

每当我看到这个属性时,它都是空白的。

Within a C# class project, there's the Properties file called AssemblyInfo.cs. Within this file are a series of assembly attributes including AssemblyTitle, AssemblyDescription, and so on, which are used to describe certain details about the compiled project. One of these is AssemblyCulture.

I understand what the others are used for, but What is AssemblyCulture used to describe? Language? Currency? A bit of both?

Whenever I've seen this property, it's been left blank.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

等风也等你 2024-12-11 11:26:53

来自文档

编译器使用该属性来区分主程序集和附属程序集。主程序集包含代码和中立文化的资源。附属程序集仅包含特定区域性的资源,如[程序集:AssemblyCultureAttribute("de")] 中所示。将此属性放在程序集上并使用空字符串 ("") 以外的内容作为区域性名称,将使该程序集看起来像附属程序集,而不是包含可执行代码的主程序集。使用此属性标记传统代码库将破坏它,因为其他代码无法在运行时找到该库的入口点。

总结一下:该属性由框架在内部使用来标记当您向项目添加本地化资源时自动创建的附属程序集。您可能永远不需要手动将此属性设置为 "" 以外的任何内容。

From the documentation:

The attribute is used by compilers to distinguish between a main assembly and a satellite assembly. A main assembly contains code and the neutral culture's resources. A satellite assembly contains only resources for a particular culture, as in [assembly:AssemblyCultureAttribute("de")]. Putting this attribute on an assembly and using something other than the empty string ("") for the culture name will make this assembly look like a satellite assembly, rather than a main assembly that contains executable code. Labeling a traditional code library with this attribute will break it, because no other code will be able to find the library's entry points at runtime.

To summarize: This attribute is used internally by the framework to mark the satellite assemblies automatically created when you add localized resources to your project. You will probably never need to manually set this attribute to anything other than "".

情归归情 2024-12-11 11:26:53

引用文档

编译器使用该属性来区分主
组件和卫星组件。主程序集包含代码和
中立文化的资源。卫星组件仅包含
特定文化的资源,例如
[程序集:AssemblyCultureAttribute(“de”)]。将此属性设置为
程序集并使用除空字符串 ("") 之外的其他内容
文化名称将使该程序集看起来像卫星
程序集,而不是包含可执行代码的主程序集。
用这个属性标记传统的代码库会破坏它,
因为没有其他代码能够找到库的入口点
在运行时。

Quote from the documentation:

The attribute is used by compilers to distinguish between a main
assembly and a satellite assembly. A main assembly contains code and
the neutral culture's resources. A satellite assembly contains only
resources for a particular culture, as in
[assembly:AssemblyCultureAttribute("de")]. Putting this attribute on
an assembly and using something other than the empty string ("") for
the culture name will make this assembly look like a satellite
assembly, rather than a main assembly that contains executable code.
Labeling a traditional code library with this attribute will break it,
because no other code will be able to find the library's entry points
at runtime.

很快妥协 2024-12-11 11:26:53

当我用谷歌搜索你的问题时,我从本教程中得到了一个快速答案。它有一个小描述,我在下面提供,看起来您可以在其中指定本地化,但我不确定它为您的程序集做了多少工作。

AssemblyCultureAttribute 类实现 AssemblyCulture 属性,该属性用于指定程序集的区域性并指示这不是主程序集而是其附属程序集。

[ assembly: AssemblyCulture("de")] // 德语

When I googled your question I came up with a quick answer from this tutorial. It has a small description which I'm providing below and it looks like that's where you can specify localization but I'm not sure how much work it does for your assembly.

AssemblyCultureAttribute Class implements AssemblyCulture attribute which is used to specify culture of an assembly as well as indicte that this is not a main assembly but rather its satellite.

[assembly: AssemblyCulture("de")] // German
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文