Hello TS,
After analyzing your scenario, looking into the source code of
ResourceManager and testing with fuslogvw.exe, I suggest your having this
attribute in the main assembly:
[assembly: NeutralResourcesLanguageAttribute("en-US")]
http://msdn.microsoft.com/en-us/library/hhz003sc.aspx
And I believe this may optimize the performance in the following aspect:
=====================================
I looked into the source code of ResourceManager
(
http://blogs.msdn.com/sburke/archiv...tudio-to-debug-net-framework-source-code.aspx).
The functions to locate the satellite assembly is: InternalGetResourceSet,
which has this piece of code:
if (UseSatelliteAssem) {
CultureInfo lookForCulture = culture;
if (_neutralResourcesCulture == null)
_neutralResourcesCulture = GetNeutralResourcesLanguage(MainAssembly,
ref _fallbackLoc);
// If our neutral resources were written in this culture
// AND we know the main assembly does NOT contain neutral
// resources, don't probe for this satellite.
if (culture.Equals(_neutralResourcesCulture) &&
FallbackLocation ==
UltimateResourceFallbackLocation.MainAssembly) {
// Update internal state.
lookForCulture = CultureInfo.InvariantCulture;
fileName = GetResourceFileName(lookForCulture);
}
// For neutral locale, look in the main assembly
// if and only if our fallback location is MainAssembly.
if (lookForCulture.Equals(CultureInfo.InvariantCulture)) {
......
}
else
satellite = GetSatelliteAssembly(lookForCulture);
}
The function GetNeutralResourcesLanguage returns our setting in
NeutralResourcesLanguageAttribute and compares it with CurrentUICulture.
If it equals, InternalGetResourceSet retrieves the default resource file
by looking in the main assembly.
Because in 99% cases, our client's culture is en-US. The setting of
NeutralResourcesLanguageAttribute ensures that the assembly will not look
other places for the satellite assemblies in most situations. Please also
note that GetNeutralResourcesLanguage returns CultureInfo.InvariantCulture
when we do not have NeutralResourcesLanguageAttribute. In other words,
InternalGetResourceSet will not benefit from this optimization when
NeutralResourcesLanguageAttribute is not declared.
As a test, I used fuslogvw
(
http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to observe
the binding behavior of the satellite assemblies. When I set
NeutralResourcesLanguageAttribute, I see my app (CurrentUICulture = en-US)
only look for the natural resources and all the accesses are successful.
Please let me know whether the above suggestion is helpful to you. If you
have any other questions or concerns, DON'T hesitate to tell me.
Regards,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
TS said:
I'm wondering if i get a performance hit in this scenario: I believe that
the .net engine will first look for resource file matching current user's
culture and if it doesnt find it then it will go to the default resource
file (simply resourceName.resx).
If in my application i dont create a resource file for en-US and just
make it so the values in the default resource file contains the en-US
values, for these clients (99% of the time) the engine will not find an
en-US so it will use the default resource file - so is this extra check
going to affect performance at all?
thanks!