Reputation: 2723
I have a GUI and a Windows Service which need to share the model
(POCO classes).
How do I do that?
I actually seen the option to add one project to another as a reference and as a result, all public
classes can be shared.
Upvotes: 0
Views: 83
Reputation: 59
If two projects share the same code, a good thing to do is to make a reference to a third project with the shared code. So basically create a new project "Model" with your poco's.
Why is it not good to add one project to another as a reference? The GUI probably doesn't need the whole project Windows Services to operate. The same goes the other way around. The Windows Services doesn't need the GUI.
Upvotes: 2
Reputation: 4146
In general you would create a project structure as follows:
The GUI and WindowsService can both have references to the DataModel project, in which case changes to the DataModel are immediately picked up by both at compilation.
When you compile to an EXE, you will have DLLs in the same directory, one which would be MyProject.DataModel.dll. The EXE will load that DLL at runtime in order to provide access to those classes.
Upvotes: 5