locked
How to share resource files (.resx) among projects RRS feed

  • Question

  • User1308293355 posted

    Hi guys!

    I'm developing a web application through a solution consisting of several different projects; one for custom controls, one for web services etc. However, I would like to create a single project within the solution which contains all resource files (.resx). I've found some different examples of handling this, for example by implementing a ResourceManager that loads the resource files at runtime, but I don't find that kind of solution to be particularly pretty.

    What I've tried to do is to:

    • Create a separate project for the resource files
    • Copy all resource files to the newly created project
    • Reference the project from the other projects in which I want to use the resources

    However, I get an error because all the resources are automatically declared as internal. Is there any way of changing this without modifying the auto-generated code? I'm guessing the auto-generated code will be overwritten the next time I modify a resource file and re-compile it...

    Any help would be greatly appreciated! Thanks!

    Thursday, February 8, 2007 4:25 AM

Answers

  • User764555827 posted

    Hi Tednyberg,

    Not a beautiful solution, but what you can do is to declare them as public.

    Instead of modifying the auto-generated file, just copy it into a new file (it's a partial class, so you can add to it with other files). In the new file, declare the properties as public, and slightly change their names (to avoir conflicts).

    As I said, it's not so beautiful, because it will mean manually adding a new property to that file when adding a new resource.

    Personnally, I think I'd go for the ResourceManager solution you just mentioned. You can turn it into something not so awful by writing a helper class to access the resources. 

    Best regards,

    Arnaud 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 8, 2007 3:07 PM