Aspnetcore.docs: Namespaces matter

Created on 27 Dec 2018  Â·  7Comments  Â·  Source: dotnet/AspNetCore.Docs

I think it's important to point out that the namespaces for the classes used by the localizer matters a lot in locating the resources. Specifically in the sample repo. the SharedResources class is located at:
./sample/Localization/Resources/SharedResource.cs
Its namespace is just namespace Localization, however this is not the default namespace when you create the file on that path in Visual studio where you get namespace Localization.Resources. I had a hard time getting this to work until I stumbled upon this comment and decided to look into why that in-fact solved the problem.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P2 PU Source - Docs.ms

All 7 comments

@Xerillio thanks for pointing that out. You are correct. I thought I mentioned that. I hope to review this soon.

It should also be noted that if your assembly name is not the same as your default namespace, the resources will also fail to load.

@hishamco please review.

RootNamespaceAttribute came for the rescue, FYI this will be mentioned in the troubleshoot article

@ryanbrandenburg please make a PR with the initial draft addressing this. I can clean up and merge.

@Rick-Anderson I'm already addressing this in the troubleshooting section

Yeah, this is already covered here. Closing.

Was this page helpful?
0 / 5 - 0 ratings