Search code examples
c#visual-studio-2008.net-3.5projects

Visual Studio 2008 - Is it possible for two projects to share common classes?


In Visual Studio 2008 I know its possible to have one solution with two (or more) projects.

Is it possible OR How is it possible for the projects to share common class files?

For example -> Project 1 has a log file handling class. Can Project 2 reference it?

My hope is to increase code re-use and avoid two copies of the same thing that need to be maintained.

The target is Winforms C# (3.5)


Solution

  • Yes, this is definitely possible. You need to add a reference to Project 1 from Project 2 (right-click Project 2 in the Solution Explorer, choose "Add Reference...", and choose Project 1 under the "Projects" tab).

    Don't forget that the code for Project 1 and Project 2 is likely to be in different namespaces. You'll need to add the appropriate using statement(s).