On an asp.net 3.5 application I am trying to explicitly localize text. Example below from MSDN
<asp:Label ID="Label2" Runat="server" Text="<%$ Resources:LocalizedText, Msg1 %>">
The problem is it can't seem to find the resource class. I am using an asp.net application, not website. I've tried specifying the full namespace for the resource class. e.g:
<asp:Label ID="Label2" Runat="server" Text="<%$ Resources:MyProject.Web.Properties.Resources, Msg1 %>">
But no avail. Any ideas?
Forgot to mention...if I use databinding expression like this, it works:
<asp:Label ID="Label2" Runat="server" Text="<% MyProject.Web.Properties.Resources.Msg1 %>">
Update:
After spending a little time with reflector came across this in the ResourceExpressionBuilder:
private static IResourceProvider GetGlobalResourceProvider(string classKey)
{
string str = "Resources." + classKey;
CacheInternal cacheInternal = HttpRuntime.CacheInternal;
string key = "A" + str;
IResourceProvider provider = cacheInternal[key] as IResourceProvider;
if (provider == null)
{
EnsureResourceProviderFactory();
provider = s_resourceProviderFactory.CreateGlobalResourceProvider(classKey);
cacheInternal.UtcInsert(key, provider);
}
return provider;
}
So it looks like it is expecting a namespace of Resources.xxx. My current resource file resides in WebApp > Properties > Resources with the web application's namespace. Think that is the problem.