Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

How to share Code

I have a .sln containing 3 separate projects.  I'd like to create a class that is shared across each of these projects.  How do I do this?  Do I have to create another project?  This is basically for my function library which in VB6 I just had in a Module that I added in to my projects (from a single path).  Thanks for the help.
0
deshi777
Asked:
deshi777
  • 3
2 Solutions
 
RonaldBiemansCommented:
Hi deshi777, Yes create another project put your class in there, and then add a reference to this class in your other 3 projects
0
 
RonaldBiemansCommented:
You add the reference by choosing add reference in the project (in the solution explorer) and in there choose the project tab
0
 
Joe_GriffithCommented:
You can also just link the file that contains the class to each project.  This effectively duplicates the code in each project but it is easy to maintain.  Here's how.

Add a file containing the class to one project.
Right click on project two and select "add an existing item".
Drill down to the class file that was added to the the first project.
Instead of clicking the OK button, click the little down arrow next to the ok button and select "Link File".
This will add a shortcut in the second project that points to the class in the first project.

0
 
RonaldBiemansCommented:
If you want to use your class in other solutions aswell, then the best way would be to create a separate solution with this class and link it the way Joe_griffith described
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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