|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating Global Resources (resx, .NET 2.0)I'm working on a large solution, comprised on numerous Projects, and I would like to have one central projects that contains a set of global RESX Resources. It doesn't make sense to have various resources (strings, images, etc...) scattered through the application; having them all in one central area will be a huge boon. The problem that I'm running into is being able to access these resources from external assemblies. I have created a "CompanyResources" Assembly, that contains a Resources.resx with all my resources. Code is then automatically generated for this, and placed in a Resources.Designer.cs file. For classes residing in my CompanyResources assembly, I have strongly typed access to the resources. For example, if I have an image titled "MATERIAL_REACTANT", I can access this image from within the resources assembly with: Properties.Resources.MATERIAL_REACTANT; Unfortunately, I cannot get strongly typed access to these resources from classes outside of the resources assembly. If I examine the autogenerated code in Resources.Designer.cs, I see that the class and all resource properties are "internal": internal class Resources { ... internal static System.Drawing.Bitmap MATERIAL_REACTANT .... } Obviously there is no way of accessing these properties from outside of the assembly, when things are internal. Is there a way to get around this? I did find a way to access these resources from other assemblies by doing the following: private System.Resources.ResourceManager resources_ = new System.Resources.ResourceManager("CompanyResources.Properties.Resources", System.Reflection.Assembly.Load("CompanyResources")); The downside of doing this is that I lose strongly typed access (and intellisense) to the resources. So instead of: resources_.MATERIAL_REACTANT I have to do: resources_.GetObject("MATERIAL_REACTANT"); It seems that there must be some way around this. Clearly one of the benefits of .NET Resources is being able to have strongly typed access, and it would seem that having one global location for all resources should be possible. Any suggestions? Thanks, Spencer Miles |
|||||||||||||||||||||||