How can I share a resource File between 2 projects in the same Solution?

D

Daniel Jeffrey

I have created a Resource file that stores common icons used in my projects.

I have a solution that contains 2 projects, and I keep getting errors if I
add the resource file to both projects.

It complains about duplicates etc etc.

I have tried adding it to the Solution, but then it doesn't appear in the
Designer under resources in the Project.

Any help?

Thanks

Daniel
 
L

Larry Smith

I have created a Resource file that stores common icons used in my
projects.

I have a solution that contains 2 projects, and I keep getting errors if I
add the resource file to both projects.

It complains about duplicates etc etc.

I have tried adding it to the Solution, but then it doesn't appear in the
Designer under resources in the Project.

Any help?

Create a new project and call it "Common" (or whatever). Add your shared
resources using this free utility (kudos to the author for a terrific
contribution)

http://dmytro.kryvko.googlepages.com/#feedback
 
D

Daniel Jeffrey

thanks
this method does work in its own way
but is there a non 3rd party way?

We have many development machines, and moving to c# was designed to minimize
the amount of effort involved in making things work across machines /
environments

Dan
 
L

Larry Smith

thanks
this method does work in its own way

It's the very same technique that MSFT itself uses in VS (see
"ResXFileCodeGenerator") except that his version renders all resources
public instead of internal. I believe he even put in a request to MSFT to
add this as an option in a future release (which they should have done in
the first place). Moreover, it even improves upon MSFT's version by adding a
"format" mechanism you can read about at the link. In any case, it's almost
a certainty that his tool relies on the same native .NET class that MSFT
itself apparently uses. See "StronglyTypedResourceBuilder" in MSDN. IOW, it
appears to be reasonably safe. For what it's worth, I wouldn't simply
install just any 3rd-party software myself. I'm extremely reluctant to
install anything that doesn't have MSFT's name attached to it. However,
because it really is just an enhanced wrapper around MSFT's own class, I
consider the risk to be minimal. The author also appears to be experienced
and MSFT certified (if you believe his bio). Note that this tool also fits
naturally into VS exactly like MSFT's own version (again,
"ResXFileCodeGenerator") and I've had no problems with it whatosever.
Lastly, it really is the cleanest way of doing things so if you choose
another technique then your code will likely suffer because of it. If you
want to explore the possibilities however then you'ld have to create a
".resx" file in a common (shared) library and expose these resources
yourself somehow (probably by creating a class that exposes them using
public instead of internal methods which is what the
"StronglyTypedResourceBuilder" class does for you - you'ld therefore be
reinventing his tool all over again).
We have many development machines, and moving to c# was designed to
minimize the amount of effort involved in making things work across
machines / environments

While that may be an issue for some it shouldn't be IMO. It's really no
different then each developr having to install whatever 3rd-party tools are
required for your application. That could be 3rd-party controls, a DB
engine, or in this case, a VS enhancement (similar to installing a 3rd-party
AddIn). My main concern is that because it's free, it's really unsupported
and perhaps may not work in a future version of VS. Again however, I
consider the risk low because of its dependence on MSFT's native class
("StronglyTypedResourceBuilder").
 

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