Reputation: 154
I have a Solution which consists of two projects - the Manager and Viewer. Naturally, both use the same classes, e.g. Manager is used to edit data in SomeItem class instances, while Viewer is used to display it's data.
I have all class definitions in the Manager project. To use them in the Viewer project, I created the same directory hierarchy in the Viewer and linked all classes with build action set to "Compile".
But now I'm getting tons of warnings like this:
The type 'SomeItem' in 'Manager\Classes\SomeItem.class.cs' conflicts with the imported type 'SomeItem' in 'Viewer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'Manager\Classes\SomeItem.class.cs'.
What is the best way to use the same class in two projects while having it in a single file?
Upvotes: 0
Views: 265
Reputation: 54532
I would suggest that you create a separate project with the classes you want to have in common, set application type as Class library, after doing this and compiling it you will be able to add it as a reference to both of your other projects by right clicking on references and adding it as a project reference.
Upvotes: 2