Hi I have an assembly called like X.Common.DLL. There is some resources files for multilanguage app. Let's say it Language.resx Language.en-US.resx....etc....
I have a web application which contains this above dll as reference...
So how can I use this resources file in my web applications markup side?
Text="<%$ Resources:Class, ResourceKey %>"
is not valid because of "Class" name is in another assembly...
You can easily create a wrapper class that does something like this
public class ResourceWrapper
{
private ResourceManager resourceManager;
public ResourceWrapper()
{
resourceManager = new ResourceManager("Namespace.Common", Assembly.Load("x.common"))
}
public string String(string resourceKey)
{
return ResourceManager.GetString(resourceKey);
}
}
Finding the correct name for the first param to new ResourceManager(...) can be a bit tricky sometimes. To make it easier for yourself you can call like this:
Assembly.Load("x.common").GetManifestResourceNames() and check the returned results.
If you create a static wrapper, you can make the resource calling code as simple as this:
<%= Resource.String("MyResourceKey") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With