Westwind.Globalization
Westwind.Globalization copied to clipboard
Implicit local resource files ignored when using Westwind.Globalization.DbSimpleResourceProviderFactory
It took me two days to figure this out! Similar to #14, when I use DbSimpleResourceProviderFactory in my .NET 4.5 WebForms application, implicit localization of local resources does not work while global resource files seem okay. In Web.config
I have:
<globalization resourceProviderFactoryType="Westwind.Globalization.DbSimpleResourceProviderFactory,Westwind.Globalization.Web" />
and in the .aspx I have:
<asp:Localize ID="PurposeHeader" runat="server" meta:resourcekey="PurposeHeader" />
<asp:TextBox runat="server" ID="txtEmail" meta:resourcekey="txtEmail" />
If I use DbResourceProviderFactory instead I get runtime error:
[TypeLoadException: Could not load type 'Westwind.Globalization.DbResourceProviderFactory' from assembly 'Westwind.Globalization'.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +71
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +41
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +38
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +67
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +39
If I comment out the globalization
tag then the local resource file values are applied to the asp:Localize
and asp:TextBox
controls. I am on vacation for a week so I have not yet tried what @RickStrahl suggested in #14 - to add a resource call in Application_Init() to force the provider to spin up.
Is there possibly a bug somewhere, or can anyone think of any other recommendations? Thanks!