470,815 Members | 1,147 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

VS .NET 2005 Global Resources

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:


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

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:

I have to do:
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?

Spencer Miles

Feb 17 '06 #1
1 3066
Figured out a solution...


Feb 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.