Sharing a common CS file throughout Multiple Projects?

  • Thread starter Thread starter Harry Whitehouse
  • Start date Start date
H

Harry Whitehouse

I'm developing a small class which will be used in a number of distinct C#
projects. This small class is undergoing constant change/refinement as I
try to employ it in the different projects.

I'm trying to maintain a *single* copy of the CS file that can be used in
the multiple .NET projects. But I'm observing that when you add a CS file
to a given .NET project, subsequent modifications to that file are only
saved in the current project.

Perhaps I've added the common CS file to the projects improperly. I went to
the righthand project node pane for project A and right clicked, selecting
Add Existing. Then I browsed to the directory for project B and added this
common CS file. But again, modifications to that file made when I'm in
Project A don't make it automatically to Project B.

If anyone has an idea of how to share a common source file over multiple
projects, I'd love to hear it!

TIA

Harry
 
Hi Harry,

When you select Add Existing, don't click the Open button. Instead, click
the drop-down arrow beside the Open button and select "Link File".

Joe
 
As you can see from another answer, you can link the source code rather than
add existing.

I'm wondering, why not just compile the class into an assembly and reference
it from multiple projects? That's certainly the most "traditional" way to
do this, and it isn't more expensive in any way...

--- Nick
 
Joe -- Thanks so much! That's something I wouldn't have noticed!!

Thanks too to Nick. I'm finding that I have to tweak the source code of
this common module as I integrate it into the various projects. So I don't
think I'm ready to integrate it as a compiled resource because it's still
under development. (I hope I'm properly interpreting your suggestion.)
 
Back
Top