Best method share code between separate projects/solutions in Visual Studio? RRS feed

  • Question

  • User-289010069 posted

    I'm trying to figure out the best way to share code between several web applications(VS2010, VS2019).  I've started adding class library projects to a solution with generic code that I plan to reuse in several web applications.   Can someone offer any advice on the questions below?

    1. Any issues with adding class library projects to a solution in order to share/reuse code?
    2. Should I reference projects or compiled .dll from the code library solution in the existing web applications? 
    3. Is there a better option to share code between projects? 
    Monday, March 8, 2021 7:47 PM

All replies

  • User475983607 posted

    Class library are used to share code.  Just create a reference to the library dll or drop the dll in the bin directly of the web project.  

    Monday, March 8, 2021 10:33 PM
  • User-1982062310 posted

    You may want to consider creating Nuget packages with your class libraries to be hosted on a local NuGet server.

    That gives you a number of advantages over linking to DLLs locally, and they might not be relevant in your situations, but definitely play important role when you have more than one dev on the team or need to version library code (say some older, rarely-updated solutions need older version of a particular library).

    Monday, March 8, 2021 11:20 PM