473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sharing Code files

How do I share code across files in C#, without including a reference to a
class library.

Here's what I want to do. I have a device I want to talk to. It's a
machine in a factory. It can talk on a serial port, or over ethernet.
Either way it's talking, it sends the same data. So, I encapsulate the data
structure in a class, and I stick the class in a .cs file.

Now, I want to create three projects, and they all will deal with the same
data structure. I create a solution with three projects. One is a windows
project for a device that will talk to one device over a serial port. One is
a windows project that talks to multiple devices over ethernet. One is a
pocket PC application that talks to one device on a serial port.

My thought was that I could add the class file to each of the three
projects, and then in each of the projects the file would end up getting
compiled and included in each of the three projects, and I could use the
class. Imagine my surprise when I added the file, and it made a copy,
putting it into the directory for the project. Since there are three copies,
now when I make changes to the class, I can't make them in one spot.

This is something pretty common in C, where I have a directory of commonly
used functions, and a make file that points to the directory where they
reside. Alternatively in C, I have sometimes used #include directives, and
just included the class definition. Never liked that solution much, but it
worked.

Can I add an existing class to a project without making a copy? Can I share
code between two projects, without sharing a class library, with its dll
(which couldn't work anyway, because I have Pocket PC and regular Windows
projects in the same solution)
Jun 7 '06 #1
2 2259
On Wed, 7 Jun 2006 14:39:01 -0700, David wrote:
Can I add an existing class to a project without making a copy? Can I share
code between two projects, without sharing a class library, with its dll
(which couldn't work anyway, because I have Pocket PC and regular Windows
projects in the same solution)


Why wouldn't the DLL work? Anyway, you can share a file across multiple
projects if you really want to (although this might cause confusion among
maintainers of your program): when you choose to add an existing file to
your project, in the open file dialog, click on the small arrow beside the
open button and choose Link File instead of Open.
Jun 7 '06 #2


"Mehdi" wrote:
On Wed, 7 Jun 2006 14:39:01 -0700, David wrote:
Can I add an existing class to a project without making a copy? Can I share
code between two projects, without sharing a class library, with its dll
(which couldn't work anyway, because I have Pocket PC and regular Windows
projects in the same solution)


Why wouldn't the DLL work? Anyway, you can share a file across multiple
projects if you really want to (although this might cause confusion among
maintainers of your program): when you choose to add an existing file to
your project, in the open file dialog, click on the small arrow beside the
open button and choose Link File instead of Open.


Thanks. That should solve the problem.

The DLL won't work because the code has to be shared between Pocket PC and
Windows.
Jun 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Neve | last post by:
Hello, This question is related to sharing .Net projects across solutions and is reposted from the SourceSafe group. We have several different solutions and want to share common assemblies...
1
by: JoeS | last post by:
Is there anyway to share a single pch file between projects in VC 7.0? I have 300+ projects each of which creates its own pch. All projects include the exact same header files in the precompiled...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
16
by: Robert W. | last post by:
I'm building a solution that has 1 component for the Desktop and 1 component for the Pocket PC. (Though this isn't a mobile question). I have a data library that will be shared on both platforms....
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
3
by: Shikari Shambu | last post by:
Hi All, I have a situation where multiple applications are sharing some pages/ controls. So, I have a separate common project that has the common pages/ controls. My question is how do I...
1
by: bruce.1 | last post by:
I'm trying to figure a way for a remote user -- using ASP.NET -- to share files on a local office LAN. The remote user would go to an ASP.NET website (on the LAN), mark the files they want, and...
1
by: Joe | last post by:
While I understand that Server Side Includes still work, I realize it's not the best practice for sharing code such as a common set of includes between screens. In ASP.NET I've already built...
2
by: James | last post by:
Hi all, I am new to ASP.NET. I am currently working on a project with VB, .NET 1.1 on a Windows 2000 server. I have two files C:\Inetpub\wwwroot\test\test.aspx...
2
by: Jeff Dege | last post by:
I'm working with a group that's been doing C++ coding for quite a long time, now, and in that environment we've pretty much worked out development practices that serve us well. We've been doing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.