473,799 Members | 3,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2582
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.c om> wrote in message
news:O5******** *****@TK2MSFTNG P10.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 "traditiona l" way to
do this, and it isn't more expensive in any way...

--- Nick

"Harry Whitehouse" <ha***@envmgr.c om> wrote in message
news:O5******** *****@TK2MSFTNG P10.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5407
by: RK | last post by:
Hi I am working on C# application, where in I may require just one app.config for the C#.NET solution with multiple windows application projects. I know one web.config can be used for multiple projects, can I use app.config is the same way?? thanx in advance. RK
5
5379
by: cybertof | last post by:
Hi ! What is the common use of sharing a single .cs across multiple project files ? I think it's to share common classes between projects. I have actually a .cs file shared accross multiple projects in a same solution. It's nice to have a common "set" of Classes. Is this the only way to share classes between projects ?
1
2085
by: Jody Gelowitz | last post by:
Within ASP.NET, is it possible to use a single .vb file and have it shared (or accessed) between multiple projects without having that file being copied to each project folder? ie. C:\Projects\MyProject1 (project 1) C:\Projects\MyProject2 (project 2) C:\Projects\CommonFiles\MyCommonFile.vb (common file directly accessed and compiled from Project1 and Project2)
2
1002
by: Crirus | last post by:
Hello Some days ago was posted the same question... I cant find the thread, but remember something like using link file instead open... I tryed that and have a msg that say the file allready exist in that directory...any thoughts? Crirus
6
1235
by: UJ | last post by:
I have a couple of files (type definitions, constants, ...) that I want to use in multiple projects. How do I make it so that I have only one copy of the file for multiple projects? If I do add existing to a project, it copies the file to the project directory. I'd like to have a single directory (called something like library) that has all the common source code in it that then gets referenced from the projects. TIA. Jeffrey.
13
3344
by: Paul Cheetham | last post by:
Hi, I have two projects where I want to use the same source file in each project. If I add the file to each project, then a local copy is made. I want to be able to have a single source file used by both projects so that I only have to change one file. I am using compiler directives within the file, and so I can't just build it into a DLL and do it that way, I really do need to make both
2
3108
by: Paul Cheetham | last post by:
Hi, We are developing a large modular application, and in order to simplify splitting of work between developers etc. we want to develop it using several different projects, and then combine the results into a single site. We plan to do this by having a 'Site' folder in which the main project will sit, with each of the other projects as a sub-folder of this. The main project has master pages defined, as well as custom error pages etc....
10
1194
by: Scott Townsend | last post by:
So I'm trying to Write a Backend to something and in testing I decided to create a generic front end app that can simulate the passed in Data. So I have 2 projects in my solution, though I'm finding that I've created classes, structs, enums, constants that are going to be neede by both. I don't want to have one project reference the other as they are not 'related' I want some 3rd project or something that I put all the stuff in. Then...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10025
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.