Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Assembly Culture

Tags:

c#

.net

How do you change the assembly language in a C# application? There is a problem when we are using

[assembly:AssemblyCulture("en-US")]

There is an error:

Error emitting'System.Reflection.AssemblyCultureAttribute' attribute -- 'Executables cannot be satellite assemblies, Culture should always be empty'

like image 287
abhi294074 Avatar asked Feb 09 '12 05:02

abhi294074


Video Answer


2 Answers

You should use

[assembly: AssemblyCulture("")] 

as the compiler suggests.

To define default culture, you should use

[assembly: NeutralResourcesLanguage("en-US")]
like image 32
Lex Li Avatar answered Sep 28 '22 09:09

Lex Li


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 "".

ref: https://stackoverflow.com/questions/7402206/in-a-c-sharp-class-project-what-is-assemblyculture-used-for

like image 124
Ammar Abdul Wadood Avatar answered Sep 28 '22 10:09

Ammar Abdul Wadood