We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Sharing code between projects

bjqrn
bjqrn asked
on
Medium Priority
211 Views
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!
Comment
Watch Question

Commented:
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

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.
Commented:
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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
thanks alot!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.