Hello,
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
"CompanyResourc es" Assembly, that contains a Resources.resx with all my
resources. Code is then automatically generated for this, and placed
in a Resources.Desig ner.cs file. For classes residing in my
CompanyResource s assembly, I have strongly typed access to the
resources. For example, if I have an image titled "MATERIAL_REACT ANT",
I can access this image from within the resources assembly with:
Properties.Reso urces.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.Desig ner.cs, I see
that the class and all resource properties are "internal":
internal class Resources {
...
internal static System.Drawing. Bitmap MATERIAL_REACTA NT
....
}
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.Resource s.ResourceManag er resources_ = new
System.Resource s.ResourceManag er("CompanyReso urces.Propertie s.Resources",
System.Reflecti on.Assembly.Loa d("CompanyResou rces"));
The downside of doing this is that I lose strongly typed access (and
intellisense) to the resources. So instead of:
resources_.MATE RIAL_REACTANT
I have to do:
resources_.GetO bject("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