[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

default resource file without culture information is performance hit?

TS

8/15/2008 3:12:00 PM

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!


7 Answers

Jialiang Ge [MSFT]

8/18/2008 7:20:00 AM

0

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/hhz...

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/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source...).
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/librar...(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 (jialge@online.microsoft.com, 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:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#not....

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&am....
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

"TS" <manofsteele1@nospam.nospam> wrote in message
news:ukq92ju$IHA.5192@TK2MSFTNGP04.phx.gbl...
> 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!
>


jialge

8/18/2008 7:57:00 AM

0

Hello TS,

I forgot to emphasize one point in my last reply:

Please make sure that ALL your assemblies using resource assemblies have
the NeutralResourcesLanguageAttribute in AssemblyInfo.cs

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

If one assembly that uses the resource assembly does not have this
attribute, this assembly won't benefit from the optimization. In other
words, this assembly will still look for the resource dll in GAC and the
current/parent directory and fail to find it.

Regards,
Jialiang Ge
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:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

jialge

8/25/2008 10:24:00 AM

0

Hello TS,

I am writing to check the status of the issue on your side. Would you mind
letting me know the result of the suggestions? If you need further
assistance, feel free to let me know. I will be more than happy to be of
assistance.

Have a great day!

Regards,
Jialiang Ge (jialge@online.microsoft.com, 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:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

TS

9/9/2008 6:04:00 PM

0

so you are saying that with this assembly attribute, i can just have the
default resource file sample.resx and don't need sample.en-US.resx and
there'll be no performance hit?

thanks!

"Jialiang Ge [MSFT]" <jialge@online.microsoft.com> wrote in message
news:%23rnJILQAJHA.3964@TK2MSFTNGP06.phx.gbl...
> 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/hhz...
>
> 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/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source...).
> 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/librar...(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 (jialge@online.microsoft.com, 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#not....
>
> 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&am....
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> "TS" <manofsteele1@nospam.nospam> wrote in message
> news:ukq92ju$IHA.5192@TK2MSFTNGP04.phx.gbl...
>> 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!
>>
>
>


jialge

9/10/2008 4:51:00 AM

0

Yes, you understand it rightly. And to some extent, I think that it will
even improve the performance a little bit. (the reason was explained in my
initial reply)

Let me know whenever you have questions/concerns!

Regards,
Jialiang Ge (jialge@online.microsoft.com, 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:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

TS

9/11/2008 6:05:00 PM

0

so you're saying that if i have an assembly that calls a method in another
assembly which accesses resource information, both assemblies need the
reference?


""Jialiang Ge [MSFT]"" <jialge@online.microsoft.com> wrote in message
news:wYjPJgQAJHA.624@TK2MSFTNGHUB02.phx.gbl...
> Hello TS,
>
> I forgot to emphasize one point in my last reply:
>
> Please make sure that ALL your assemblies using resource assemblies have
> the NeutralResourcesLanguageAttribute in AssemblyInfo.cs
>
> [assembly: NeutralResourcesLanguageAttribute("en-US")]
>
> If one assembly that uses the resource assembly does not have this
> attribute, this assembly won't benefit from the optimization. In other
> words, this assembly will still look for the resource dll in GAC and the
> current/parent directory and fail to find it.
>
> Regards,
> Jialiang Ge
> 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:
> msdnmg@microsoft.com.
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> =================================================
>


Jialiang Ge [MSFT]

9/12/2008 7:00:00 AM

0

Hello TS,

No. Only the assembly that access resource information needs this attribute.
For example, assembly A references assembly B. A does not use resource
files but B does, we only need to add the NeutralResourcesLanguageAttribute
attribute in B.

Have a nice day!

Regards,
Jialiang Ge (jialge@online.microsoft.com, 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:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================

"TS" <manofsteele1@nospam.nospam> wrote in message
news:ettmvjDFJHA.5060@TK2MSFTNGP03.phx.gbl...
> so you're saying that if i have an assembly that calls a method in another
> assembly which accesses resource information, both assemblies need the
> reference?
>
>
> ""Jialiang Ge [MSFT]"" <jialge@online.microsoft.com> wrote in message
> news:wYjPJgQAJHA.624@TK2MSFTNGHUB02.phx.gbl...
>> Hello TS,
>>
>> I forgot to emphasize one point in my last reply:
>>
>> Please make sure that ALL your assemblies using resource assemblies have
>> the NeutralResourcesLanguageAttribute in AssemblyInfo.cs
>>
>> [assembly: NeutralResourcesLanguageAttribute("en-US")]
>>
>> If one assembly that uses the resource assembly does not have this
>> attribute, this assembly won't benefit from the optimization. In other
>> words, this assembly will still look for the resource dll in GAC and the
>> current/parent directory and fail to find it.
>>
>> Regards,
>> Jialiang Ge
>> 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:
>> msdnmg@microsoft.com.
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> =================================================
>>
>
>