469,636 Members | 1,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Sharing a common CS file throughout Multiple Projects?

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
3 2380
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
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
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.

Similar topics

1 post views Thread by Jody Gelowitz | last post: by
2 posts views Thread by Crirus | last post: by
13 posts views Thread by Paul Cheetham | last post: by
2 posts views Thread by Paul Cheetham | last post: by
10 posts views Thread by Scott Townsend | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.