I’m about to write a small C# WPF service which references an XML file for its configuration. I have already written the WPF interface application which creates and maintains the XML which the service will read. A lot of code has gone into the classes used by the interface and I’d like to reuse them while only maintaining one version of code.
What is the best practise for maintaining two ‘Main’ entry points in Visual Studio? One for the application and the other for the service. Is it possible to mix a WPF forms and service project type?
How can I test and run the service before it is registered as a windows service?
If I got this correctly you have one UI project and you want to reuse the code in a separate Windows Service project.
Usually this is done by moving the common shared code into a separate project, called Commons or Core. This is what you need to unit-test. Finally, you add references from the UI and Windows service projects to this shared library.
/root ... /src /app /Core /Presentation (ref to Core) /Service (ref to Core) /test /Core.Test (ref to Core)