Learn how to a build a cloud-first strategyRegister Now


Sharing code between projects

Posted on 2006-03-31
Medium Priority
Last Modified: 2010-04-24
What would be the best way of sharing code between two projects in vc.net 2003/2005. Would it be by adding the same files containing the code to both projects, making a DLL or some other way?

Im creating a TcpIP implementation and since both the server and the client must have a client I thaught it was a good idea.

It's for a course in programming and therefore I would like to implement it using interfaces and polymorphism, so the solution must be capable of that.

Any help appreciated!
Question by:bjqrn
  • 2
  • 2
LVL 48

Expert Comment

ID: 16343378
The best way is writing Dll.
One exception of this rule is code which can be placed in h-files: constants, templates, inline functions. Such files can be placed to some common directory and included to both projects.

Source file which belongs to two projects is not a good idea because of two reasons:
1) Synchronization problems between two projects.
2) Visual Studio doesn't source files in other directories and you can loose some of IDE support like Intellicense, Class View etc.

Author Comment

ID: 16343453
Is there a good tuorial on writing .NET dlls then? I need to be able to use classes as I would when writing .cpp and .h files.

I would want it to work as System.dll, System.XML.dll and such.
LVL 48

Accepted Solution

AlexFM earned 2000 total points
ID: 16344053
Make the following steps:
1) Create C++/CLI Class Library project. Add required classes to it. Every managed public class from class library is available for .NET clients.
2) Client project can be written in any .NET language. Add reference to class library to client project and use classes from library in the code.
If library and client are in different solutions, you need to browse and add library Dll in Add References dialog. If they belong to the same solution, you can select library project in the Projects tab.

Author Comment

ID: 16344349
thanks alot!

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question