• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

Sharing code between projects

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!
0
bjqrn
Asked:
bjqrn
  • 2
  • 2
1 Solution
 
AlexFMCommented:
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.
0
 
bjqrnAuthor Commented:
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.
0
 
AlexFMCommented:
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.
0
 
bjqrnAuthor Commented:
thanks alot!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now