By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,536 Members | 1,504 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,536 IT Pros & Developers. It's quick & easy.

Sharing a common CS file throughout Multiple Projects?

P: n/a
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

Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Harry Whitehouse" <ha***@envmgr.com> wrote in message
news:O5*************@TK2MSFTNGP10.phx.gbl...
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

Nov 16 '05 #2

P: n/a
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

"Harry Whitehouse" <ha***@envmgr.com> wrote in message
news:O5*************@TK2MSFTNGP10.phx.gbl...
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

Nov 16 '05 #3

P: n/a
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.)
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.