New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetAllStrings throws "No manifests exist for the current culture" #2630

Closed
aspnet-hello opened this Issue Jan 2, 2018 · 34 comments

Comments

Projects
None yet
6 participants
@aspnet-hello

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 7:56:21 AM

We have updated all our solution assemblies from 1.1.x to 2.0.1 and out of sudden this message has started to appear.

We have an MVC project that references assembly AppImpact.AspNetCore.

In assembly A we have resources for two cultures as shown on the image:

  • en
  • bs-Latn-BA

image

In MVC project, we create a localizer by using Create method on IStringLocalizerFactory with the following parameters (as shown on the images):

  • "Buttons" as baseName
  • "AppImpact.AspNetCore" as location

image

image

If we inspect created localizer instance, we can see that assembly is present in _resourceNamesCache:

image

Highlighted value is:
{[Assembly=AppImpact.AspNetCore, Version=1.2.2.0, Culture=bs-Latn-BA, PublicKeyToken=null;resourceName=AppImpact.AspNetCore.Resources.Buttons, ]}

As soon as we try to iterate through results of GetAllStrings method, we get "No manifests exist for the current culture".

image

This code was in production for more than a year. Only difference that was done was upgrade to 2.x.

Funny thing is that as soon as we rename Buttons.en.resx (or any other for that matter) to Buttons.resx (old logic with default resource), everything starts to work.

We are looking for a better solution rather than doing a mass rename of resource files.

Is this behavior as expected or there is a bug?

EDIT:

We have tried now the second overload of GetAllStrings method:

image

And now we get a different error:

image

However, in the bin folder where the build is, there is a resource file for this assembly:

image

Copied from original issue: aspnet/Localization#433

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 9:05:11 AM

This is remind me of an old bug #257, but it was solved by a temporary fix. Could you please create a minimal repo to reproduce the issue?

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 9:05:11 AM

This is remind me of an old bug #257, but it was solved by a temporary fix. Could you please create a minimal repo to reproduce the issue?

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 11:36:20 AM

Thank you for your quick response. :)

https://github.com/App-Impact-Labs/ISSUE-MissingResourceManifestExample

  1. Run Xampl.Services
  2. Navigate to /StaticResources/Get

You will get exception immediately.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 11:36:20 AM

Thank you for your quick response. :)

https://github.com/App-Impact-Labs/ISSUE-MissingResourceManifestExample

  1. Run Xampl.Services
  2. Navigate to /StaticResources/Get

You will get exception immediately.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 11:44:23 AM

Let me check ..

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 11:44:23 AM

Let me check ..

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 12:18:29 PM

Removing the en from Buttons.en.resx fixing the issue for me, because the en is not needed in case that English is the default culture.

The GetAllStrings(false) is not useful in your case while ther's no parent cultures provided

Also you can use app.UseRequestLocalization instead of setting Bosnia and Herzegovina the culture in the controller

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 12:18:29 PM

Removing the en from Buttons.en.resx fixing the issue for me, because the en is not needed in case that English is the default culture.

The GetAllStrings(false) is not useful in your case while ther's no parent cultures provided

Also you can use app.UseRequestLocalization instead of setting Bosnia and Herzegovina the culture in the controller

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 12:26:41 PM

RequestLocalization will just set CultureInfo based on inputs (query string, cookie, header).

In production we are using it, but I have removed it from here for simplicity reasons.

Yes, removing "en" culture tag from resource file name does the thing, but that is "dirty" fix as general recommendation is not to have default RESX file.

Here is one more thing that you should try - now that you have removed "en" prefix from default resource, it will work (you will not get an exception), but check what values are you getting from GetAllStrings.

You should get translations for Bosnian language - but that's not the case, so even with removal of "en" prefix, it is still not working properly.

Again, this was all working as intended with 1.x versions. It is 2.x versions that have caused for this to happen.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 12:26:41 PM

RequestLocalization will just set CultureInfo based on inputs (query string, cookie, header).

In production we are using it, but I have removed it from here for simplicity reasons.

Yes, removing "en" culture tag from resource file name does the thing, but that is "dirty" fix as general recommendation is not to have default RESX file.

Here is one more thing that you should try - now that you have removed "en" prefix from default resource, it will work (you will not get an exception), but check what values are you getting from GetAllStrings.

You should get translations for Bosnian language - but that's not the case, so even with removal of "en" prefix, it is still not working properly.

Again, this was all working as intended with 1.x versions. It is 2.x versions that have caused for this to happen.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 12:32:54 PM

Yes, removing en from resources does the thing, but that is "dirty" fix as general recommendation is not to have default RESX file.

I don't think it's a dirty fix 😄, this the default for any resource, while the default culture in .NET is en-US, I will check if this documented in the docs or I will suggest it

Yep I got the Bosnian translation, which is the right values if I'm not wrong

You should get translations for Bosnian language - but that's not the case, so even with removal of "en" prefix, it is still not working properly.

So what's the result that you expect?!!

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 12:32:54 PM

Yes, removing en from resources does the thing, but that is "dirty" fix as general recommendation is not to have default RESX file.

I don't think it's a dirty fix 😄, this the default for any resource, while the default culture in .NET is en-US, I will check if this documented in the docs or I will suggest it

Yep I got the Bosnian translation, which is the right values if I'm not wrong

You should get translations for Bosnian language - but that's not the case, so even with removal of "en" prefix, it is still not working properly.

So what's the result that you expect?!!

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 12:48:05 PM

From official documentation (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization):

image

Problem is that we have several solutions in the production that have followed this guideline.

What you are now suggesting will force us to do rename of all resource files and to also change a lot of our code that was built with presumption that there is no default resource file, but instead that there is a default culture (why otherwise set DefaultRequestCulture in RequestLocalizationMiddleware).

As for the second part - can you do a pull now, build and run again and see if you get results on Bosnian?

I have added Buttons.resx but left Buttons.en.resx as well.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 12:48:05 PM

From official documentation (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization):

image

Problem is that we have several solutions in the production that have followed this guideline.

What you are now suggesting will force us to do rename of all resource files and to also change a lot of our code that was built with presumption that there is no default resource file, but instead that there is a default culture (why otherwise set DefaultRequestCulture in RequestLocalizationMiddleware).

As for the second part - can you do a pull now, build and run again and see if you get results on Bosnian?

I have added Buttons.resx but left Buttons.en.resx as well.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:00:40 PM

I read it before a minute ago, nothing but this happen behind this by setting the NeutralResourcesLanguage attribute, so if use the following in your AssemblyInfo.cs:

[assembly: NeutralResourcesLanguage("bs-Latn-BA")]

the Buttons.resx will be the default resource, so if it's contains the Bosinian resources it will load them.
That's why you see this behavior, i'm not forcing you 😄, and with the DefaultRequestCulture you can set your default culture which is useful if the current culture is not supported the localization APIs will use it as default one

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:00:40 PM

I read it before a minute ago, nothing but this happen behind this by setting the NeutralResourcesLanguage attribute, so if use the following in your AssemblyInfo.cs:

[assembly: NeutralResourcesLanguage("bs-Latn-BA")]

the Buttons.resx will be the default resource, so if it's contains the Bosinian resources it will load them.
That's why you see this behavior, i'm not forcing you 😄, and with the DefaultRequestCulture you can set your default culture which is useful if the current culture is not supported the localization APIs will use it as default one

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 1:09:59 PM

We don't have AssemblyInfo.cs at all, but regardless of that, some libraries here are part of our internal framework that is used across different solutions, and almost each solution has a different default culture.

We cannot set default culture to be bs-Latn-BA on internal framework libraries, as it is not guaranteed it is going to be default on any solutions that depend on it.

Again, why did this stop to work with 2.x while it was working as expected with 1.x versions? What has been changed? We are trying to find some explanation over this, but nothing is available online.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 1:09:59 PM

We don't have AssemblyInfo.cs at all, but regardless of that, some libraries here are part of our internal framework that is used across different solutions, and almost each solution has a different default culture.

We cannot set default culture to be bs-Latn-BA on internal framework libraries, as it is not guaranteed it is going to be default on any solutions that depend on it.

Again, why did this stop to work with 2.x while it was working as expected with 1.x versions? What has been changed? We are trying to find some explanation over this, but nothing is available online.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:16:56 PM

I knew you don't have AssemblyInfo.cs but I would like to explain to you why this happen

What has been changed?

AFAIK, the big once are:

  • Remove dependency on Microsoft.AspNetCore.Hosting.Abstractions
  • Consider surfacing additional diagnostics information as part of LocalizedString when a resource is not found

for more details you can check the releases

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:16:56 PM

I knew you don't have AssemblyInfo.cs but I would like to explain to you why this happen

What has been changed?

AFAIK, the big once are:

  • Remove dependency on Microsoft.AspNetCore.Hosting.Abstractions
  • Consider surfacing additional diagnostics information as part of LocalizedString when a resource is not found

for more details you can check the releases

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 1:37:12 PM

Thank you really for your efforts, but so far it was not really helpful.

There has been a change in internal implementation and that change is making a huge problem for us at the moment. I am hoping that someone from the development team will shed some light on this.

Apart from the issue that we are facing, fact that adding .resx and .en.resx at the same time disables reading of existing .bs-Latn-BA.resx does not seem like everything is working as it should.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 1:37:12 PM

Thank you really for your efforts, but so far it was not really helpful.

There has been a change in internal implementation and that change is making a huge problem for us at the moment. I am hoping that someone from the development team will shed some light on this.

Apart from the issue that we are facing, fact that adding .resx and .en.resx at the same time disables reading of existing .bs-Latn-BA.resx does not seem like everything is working as it should.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:42:44 PM

@atuzovic just one more question, can you let me know why you adding both .resx and .en.resx at the same time?!!

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:42:44 PM

@atuzovic just one more question, can you let me know why you adding both .resx and .en.resx at the same time?!!

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 1:47:00 PM

Just for fun - to see the behavior. I don't see valid explanation why is it disabling .bs-Latn-BA.resx resource.

But again, that's not the point.

Point is - our solution(s) have stopped working after the upgrade and we have documented what is happening.

I am asking for official clarification/recommendation on upgrade path from 1.x to 2.x.

Can you please let us know that this is all working as expected, there is no bug, and that we should rewrite a bunch of our code / rename tons of resource files to be able to run our code?

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 1:47:00 PM

Just for fun - to see the behavior. I don't see valid explanation why is it disabling .bs-Latn-BA.resx resource.

But again, that's not the point.

Point is - our solution(s) have stopped working after the upgrade and we have documented what is happening.

I am asking for official clarification/recommendation on upgrade path from 1.x to 2.x.

Can you please let us know that this is all working as expected, there is no bug, and that we should rewrite a bunch of our code / rename tons of resource files to be able to run our code?

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:55:29 PM

Seems having both .resx and .en.resx causes a bug, perhaps this is come from underlying ResourceManager APIs, @ryanbrandenburg @pranavkm any idea about this?

BTW @atuzovic there's a localization issue that I knew in 2.0.0, could you please try to upgrade to the latest preview bits and have a try. If it's still the same hope one of the team will respond

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 1:55:29 PM

Seems having both .resx and .en.resx causes a bug, perhaps this is come from underlying ResourceManager APIs, @ryanbrandenburg @pranavkm any idea about this?

BTW @atuzovic there's a localization issue that I knew in 2.0.0, could you please try to upgrade to the latest preview bits and have a try. If it's still the same hope one of the team will respond

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 2:00:06 PM

Update to latest preview bits of what?

Solution is currently using 2.0.1 version of Microsoft.Extension.Localization. I don't see any preview available on NuGet:
https://www.nuget.org/packages/Microsoft.Extensions.Localization/

Do you want me to add specific branch of this repository to solution directly or you're suggesting something else?

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 2:00:06 PM

Update to latest preview bits of what?

Solution is currently using 2.0.1 version of Microsoft.Extension.Localization. I don't see any preview available on NuGet:
https://www.nuget.org/packages/Microsoft.Extensions.Localization/

Do you want me to add specific branch of this repository to solution directly or you're suggesting something else?

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 2:01:52 PM

I suggest to use the dev feed (nightly builds), look i will do it in your behalf and waiting until one of the team respond ..

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 2:01:52 PM

I suggest to use the dev feed (nightly builds), look i will do it in your behalf and waiting until one of the team respond ..

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 2:12:21 PM

Alright, I have updated solution to nightly build (2.1.0-preview1-27907) and it is working the same way it was working with 1.x versions. I have removed Buttons.resx from solution => there is no error and I get proper translations for bs-Latn-BA.

I have made additional commit, so you can pull solution yourself and give it a try.

So 2.0.1 has a bug clearly. Do you have any ETA on release of 2.1.0 ?

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 2:12:21 PM

Alright, I have updated solution to nightly build (2.1.0-preview1-27907) and it is working the same way it was working with 1.x versions. I have removed Buttons.resx from solution => there is no error and I get proper translations for bs-Latn-BA.

I have made additional commit, so you can pull solution yourself and give it a try.

So 2.0.1 has a bug clearly. Do you have any ETA on release of 2.1.0 ?

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 2:20:38 PM

As I told you before there's a bug I remeber in IViewLocalizer which I blogged about it here, but I'm not sure If it's the reason behind this behavior or there's something else had been fixed

Do you have any ETA on release of 2.1.0

Nope, but you can checkout https://github.com/aspnet/Home/wiki/Roadmap

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 2:20:38 PM

As I told you before there's a bug I remeber in IViewLocalizer which I blogged about it here, but I'm not sure If it's the reason behind this behavior or there's something else had been fixed

Do you have any ETA on release of 2.1.0

Nope, but you can checkout https://github.com/aspnet/Home/wiki/Roadmap

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 8:39:47 PM

Q1-Q2 2018 seems a bit undeterministic (probably targeting Build 2018) and we are stuck halfway at migrating from 1.x to 2.x.

What are the changes to get hotfix 2.0.2 for this issue in the meantime?

Again, apart from doing a mass rename, which will also affect csproj files and cause us to rewrite bunch of our code that handles versioning of translations, we don't see an easy fix to survive till 2.1.0.

Also, using nightly builds in production is not an option for us.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 8:39:47 PM

Q1-Q2 2018 seems a bit undeterministic (probably targeting Build 2018) and we are stuck halfway at migrating from 1.x to 2.x.

What are the changes to get hotfix 2.0.2 for this issue in the meantime?

Again, apart from doing a mass rename, which will also affect csproj files and cause us to rewrite bunch of our code that handles versioning of translations, we don't see an easy fix to survive till 2.1.0.

Also, using nightly builds in production is not an option for us.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 8:43:10 PM

What are the changes to get hotfix 2.0.2 for this issue in the meantime?

I think there's a patch release which I don't have it's link, but I will look for it

Also, using nightly builds in production is not an option for us.

Yep using nightly builds in production is a good option

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 8:43:10 PM

What are the changes to get hotfix 2.0.2 for this issue in the meantime?

I think there's a patch release which I don't have it's link, but I will look for it

Also, using nightly builds in production is not an option for us.

Yep using nightly builds in production is a good option

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 8:51:57 PM

I found these links 2.0.3 and 2.0.4 if you are running on premise

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 8:51:57 PM

I found these links 2.0.3 and 2.0.4 if you are running on premise

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 10:07:37 PM

If you are referring to .NET Core version, I have 2.0.4. on my dev machine already:

image

I was asking about release of 2.0.2. for Microsoft.Extensions.Localization library.

aspnet-hello commented Jan 2, 2018

From @atuzovic on Sunday, December 24, 2017 10:07:37 PM

If you are referring to .NET Core version, I have 2.0.4. on my dev machine already:

image

I was asking about release of 2.0.2. for Microsoft.Extensions.Localization library.

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 11:07:01 PM

Oops, sorry it's my mistake

aspnet-hello commented Jan 2, 2018

From @hishamco on Sunday, December 24, 2017 11:07:01 PM

Oops, sorry it's my mistake

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @mkArtakMSFT on Wednesday, December 27, 2017 9:27:12 AM

@ryanbrandenburg, can you please check and see which change fixed the issue in 2.1.0 release (from 2.0) and see whether we can come up with a simpler workaround?

aspnet-hello commented Jan 2, 2018

From @mkArtakMSFT on Wednesday, December 27, 2017 9:27:12 AM

@ryanbrandenburg, can you please check and see which change fixed the issue in 2.1.0 release (from 2.0) and see whether we can come up with a simpler workaround?

@aspnet-hello

This comment has been minimized.

Show comment
Hide comment
@aspnet-hello

aspnet-hello Jan 2, 2018

From @MookieFumi on Saturday, December 30, 2017 2:21:55 AM

The same issue like another mates.

var strings = _sharedLocalizer.GetAllStrings();

Message: No manifests exist for the current culture.

StackTrace:

 at Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.GetResourceNamesFromCultureHierarchy(CultureInfo startingCulture)
   at Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.<GetAllStrings>d__15.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
> dotnet --info                                       
Herramientas de la línea de comandos .NET (2.1.3)     
                                                      
Product Information:                                  
 Version:            2.1.3                            
 Commit SHA-1 hash:  a0ca411ca5                       
                                                      
Runtime Environment:                                  
 OS Name:     Windows                                 
 OS Version:  10.0.16299                              
 OS Platform: Windows                                 
 RID:         win10-x64                               
 Base Path:   C:\Program Files\dotnet\sdk\2.1.3\      
                                                      
Microsoft .NET Core Shared Framework Host             
                                                      
  Version  : 2.0.4                                    
  Build    : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff 

Forwarded from aspnet/Localization#406
Thank you so much.

aspnet-hello commented Jan 2, 2018

From @MookieFumi on Saturday, December 30, 2017 2:21:55 AM

The same issue like another mates.

var strings = _sharedLocalizer.GetAllStrings();

Message: No manifests exist for the current culture.

StackTrace:

 at Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.GetResourceNamesFromCultureHierarchy(CultureInfo startingCulture)
   at Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.<GetAllStrings>d__15.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
> dotnet --info                                       
Herramientas de la línea de comandos .NET (2.1.3)     
                                                      
Product Information:                                  
 Version:            2.1.3                            
 Commit SHA-1 hash:  a0ca411ca5                       
                                                      
Runtime Environment:                                  
 OS Name:     Windows                                 
 OS Version:  10.0.16299                              
 OS Platform: Windows                                 
 RID:         win10-x64                               
 Base Path:   C:\Program Files\dotnet\sdk\2.1.3\      
                                                      
Microsoft .NET Core Shared Framework Host             
                                                      
  Version  : 2.0.4                                    
  Build    : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff 

Forwarded from aspnet/Localization#406
Thank you so much.

@ryanbrandenburg

This comment has been minimized.

Show comment
Hide comment
@ryanbrandenburg

ryanbrandenburg Jan 2, 2018

Member

The change that fixed this for 2.1.0 was aspnet/Localization#413. The original problem was that corefx removed the GetResourceSet API from ResourceManager, we worked around that with aspnet/Localization#264 (essentially trying to get the full resource set ourselves by hand) but that solution had the problem we see here which is why we started using the GetResourceSet API again once it was available.

After experimenting for a bit I couldn't find any way to "work around" this while still using ResourceManagerStringLocalizer in 2.0.x. If we think this meets the bar for patch I believe I know the general fix to make. Experience in this area tells me there will be edge cases which our improved solution still doesn't quite work for because we don't have the full context and platform knowledge that GetResourceSet does.

Member

ryanbrandenburg commented Jan 2, 2018

The change that fixed this for 2.1.0 was aspnet/Localization#413. The original problem was that corefx removed the GetResourceSet API from ResourceManager, we worked around that with aspnet/Localization#264 (essentially trying to get the full resource set ourselves by hand) but that solution had the problem we see here which is why we started using the GetResourceSet API again once it was available.

After experimenting for a bit I couldn't find any way to "work around" this while still using ResourceManagerStringLocalizer in 2.0.x. If we think this meets the bar for patch I believe I know the general fix to make. Experience in this area tells me there will be edge cases which our improved solution still doesn't quite work for because we don't have the full context and platform knowledge that GetResourceSet does.

@mkArtakMSFT

This comment has been minimized.

Show comment
Hide comment
@mkArtakMSFT

mkArtakMSFT Jan 19, 2018

@ryanbrandenburg, can you please investigate this further and see what options do we have? Is this really something customers can confidently work around or not?

mkArtakMSFT commented Jan 19, 2018

@ryanbrandenburg, can you please investigate this further and see what options do we have? Is this really something customers can confidently work around or not?

@ryanbrandenburg

This comment has been minimized.

Show comment
Hide comment
@ryanbrandenburg

ryanbrandenburg Jan 20, 2018

Member

I can confirm that the workaround of having the resource for your neutral language be named Test.resx instead of Test.en-US.resx works.

Member

ryanbrandenburg commented Jan 20, 2018

I can confirm that the workaround of having the resource for your neutral language be named Test.resx instead of Test.en-US.resx works.

@hishamco

This comment has been minimized.

Show comment
Hide comment
@hishamco

hishamco Jan 20, 2018

Contributor

I quote from what @atuzovic said before

adding .resx and .en.resx at the same time disables reading of existing .bs-Latn-BA.resx does not seem like everything is working as it should

Contributor

hishamco commented Jan 20, 2018

I quote from what @atuzovic said before

adding .resx and .en.resx at the same time disables reading of existing .bs-Latn-BA.resx does not seem like everything is working as it should

@amoerie

This comment has been minimized.

Show comment
Hide comment
@amoerie

amoerie Feb 20, 2018

This is a workaround that is confirmed working for us, until this issue is resolved:

    private static readonly FieldInfo ResourceManagerField = typeof(ResourceManagerStringLocalizer)
      .GetField("_resourceManager", BindingFlags.Instance | BindingFlags.NonPublic);

    public IDictionary<string, string> GetAllStrings(IStringLocalizer stringLocalizer) {
        if (!(stringLocalizer is ResourceManagerStringLocalizer localizer)) 
            throw new ArgumentException("Until https://github.com/aspnet/Home/issues/2630 is resolved, a ResourceManagerStringLocalizer is required");

        if (!(ResourceManagerField.GetValue(localizer) is ResourceManager resourceManager))
            throw new ArgumentException("Expected a ResourceManager here");
        
	var resourceSet = resourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, false);
        if (resourceSet == null) ...; // do something meaningful. This can happen when you create an IStringLocalizer for an MVC controller which does not have a corresponding resx file.
        
	return resourceSet.Cast<DictionaryEntry>()
          .ToDictionary(entry => entry.Key.ToString(), entry => entry.Value.ToString());
    }

Confirmed working with TargetFramework "net471" using .NET SDK 2.1.4

This uses the fact that the "GetResourceSet" method is perfectly available on .NET Framework, although I must admit some of the details of this whole issue still elude me.

amoerie commented Feb 20, 2018

This is a workaround that is confirmed working for us, until this issue is resolved:

    private static readonly FieldInfo ResourceManagerField = typeof(ResourceManagerStringLocalizer)
      .GetField("_resourceManager", BindingFlags.Instance | BindingFlags.NonPublic);

    public IDictionary<string, string> GetAllStrings(IStringLocalizer stringLocalizer) {
        if (!(stringLocalizer is ResourceManagerStringLocalizer localizer)) 
            throw new ArgumentException("Until https://github.com/aspnet/Home/issues/2630 is resolved, a ResourceManagerStringLocalizer is required");

        if (!(ResourceManagerField.GetValue(localizer) is ResourceManager resourceManager))
            throw new ArgumentException("Expected a ResourceManager here");
        
	var resourceSet = resourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, false);
        if (resourceSet == null) ...; // do something meaningful. This can happen when you create an IStringLocalizer for an MVC controller which does not have a corresponding resx file.
        
	return resourceSet.Cast<DictionaryEntry>()
          .ToDictionary(entry => entry.Key.ToString(), entry => entry.Value.ToString());
    }

Confirmed working with TargetFramework "net471" using .NET SDK 2.1.4

This uses the fact that the "GetResourceSet" method is perfectly available on .NET Framework, although I must admit some of the details of this whole issue still elude me.

@ryanbrandenburg

This comment has been minimized.

Show comment
Hide comment
@ryanbrandenburg

ryanbrandenburg Feb 28, 2018

Member

In response to this we've decided that we also need to clean up and clarify our localization documentation in this area, so I've filed #2905.

Member

ryanbrandenburg commented Feb 28, 2018

In response to this we've decided that we also need to clean up and clarify our localization documentation in this area, so I've filed #2905.

@Eilon

This comment has been minimized.

Show comment
Hide comment
@Eilon

Eilon Feb 28, 2018

Member

Just checking: we can consider this for the next patch, but was the work already done for 2.1 (dev)? Or is there a separate issue tracking that?

Member

Eilon commented Feb 28, 2018

Just checking: we can consider this for the next patch, but was the work already done for 2.1 (dev)? Or is there a separate issue tracking that?

@ryanbrandenburg

This comment has been minimized.

Show comment
Hide comment
@ryanbrandenburg

ryanbrandenburg Feb 28, 2018

Member

Yes, this work is done for 2.1. We fixed it in aspnet/Localization#413 when they added the GetAllStrings API back to ResourceManager.

Member

ryanbrandenburg commented Feb 28, 2018

Yes, this work is done for 2.1. We fixed it in aspnet/Localization#413 when they added the GetAllStrings API back to ResourceManager.

@Eilon

This comment has been minimized.

Show comment
Hide comment
@Eilon

Eilon Mar 16, 2018

Member

Discussed within the team and we feel that given there is a workaround for this issue in 2.0, and that it's fixed in the upcoming 2.1 release, we will not patch this.

Member

Eilon commented Mar 16, 2018

Discussed within the team and we feel that given there is a workaround for this issue in 2.0, and that it's fixed in the upcoming 2.1 release, we will not patch this.

@Eilon Eilon closed this Mar 16, 2018

@Eilon Eilon added wontfix and removed patch-proposed labels Mar 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment