How to share projects between solutions

R

Ron L

I have an application that I am developing that is a front end for a SQL
database. We will also be developing a subset of the UI that will work as a
(mainly) standalone client that will make a connection to the database, copy
the relevant data to a local file, and disconnect from the database. The
users will then be able to make modifications using the UI, and when a
connection is available they can connect and upload their changes. Since I
want the majority of the UI to be the same for both clients, I have divided
up my solution for the main (always connected) client to seperate the
sections that will be used in both applications from those that will be
unique to one or the other. My question is: what are the mechanics of using
a project in multiple solutions, particularly in that some of the items that
the shared project must reference will be different between the 2 solutions.
(E.G. there will be a DataConnection reference which in the connected client
will need to connect to the database and in the disconnected client will
need to "connect" to the local file.)

TIA
Ron L
 
C

Carlos J. Quintero [.NET MVP]

Instead of sharing whole projects, I would share code files. That is, I
would create 2 projects but using the same code files from a shared folder.
You can use shared code files using Add Existing Item menu of a project, and
in the dialog drop down the Open button (with an arrow) and use Link File
instead of Open.

Also, you may want to use conditional compilation is some file or method
must have a different behavior depending on the project. Projects allow you
to define compilation constants (Project properties, Configuration
Properties, Build node) and you can use them in your code:

#If PROJECT_A Then
' Connect to remote database
....
#Else
' Connect to local database
....
#End If

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
R

Ron L

Carlos
Thank you for the response. I had been wondering if seperate projects
with common code files was the way to do it, or if there was a better way.

Ron L
 
C

Carlos J. Quintero [.NET MVP]

Hi Ron,

Notice that while you can create different configurations for a project,
such as ProjectA_Debug, ProjectA_Release, ProjectB_Debug,ProjectB_Release,
the assembly name is the same for all of them (it is not configurable per
configuration, only the output folder), so if you want 2 assemblies, you
need 2 projects...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top