resources in separate assembly - ugly :(

S

Sergei Shelukhin

Hi.
We have a resource assembly that is separate and is used by a class
library assembly, a web app, web service set (all in separate
projects). Windows app is also potentially possible.

First of all, VS2005 generates resource wrappers as internal, so we
have to use InternalsVisibleTo to make intellisense etc possible for
resources.
Then, with this model, all the cool localization features of ASP.NET
2.0 are not possible. Is there any way to circumvent this and take
advantage of automatic resource binding, <$ expressions etc if
resources reside in a different assembly?
 
R

Rick Strahl [MVP]

I don't think so. ASP.NET's resource mechanism works through custom
compilation of the raw RESX files and referencing them through a more or
less custom scheme (the resources get compiled into a special resource
assembly with a dynamic name that the provider reads out of). I'm not aware
of a way to extend that to include external resources.

However, nothing is stopping you from calling external resource assemblies
directly through a ResourceManager.You could build your own expression
parser that read resources from external assemblies. The <$ $> parsing is
extensible in .NET and you can certainly create your own mechanism for it.

Although that may not be worth it - it's just as easy to use a standard
class expression in the page and make a static method call and call it from
the page:

<%= App.Trans("ResourceFile","ResourcesId") %>

which would work just as well where App.Trans() would read your resource
from the external resource you've created.

+++ Rick ---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top