I have a project that is being deployed as a Windows service. However, for local development purposes, it would be useful to run it as a console application. At the moment, I have a Called ReportingHost class that provides my main functionality, and a class called ReportingServiceHost, which inherits from ServiceBase and allows me to run the application as a service. There is also a program class with a main method that calls ServiceBase.Run in my ReportingServiceHost.
I think I need to write a ReportingConsoleHost class that allows me to run functionality in the console. Then I need to change my Main in order to respond to the command line switch and select one or the other. These are the two bits that I encountered.
I looked over this one and tried to use this code, but my application will exit immediately, it does not display the console window and it does not wait for Enter before closing.
Part of the problem is that I donβt have a deep understanding of how this works. the final template for sharing my functionality, two different ways to use this functionality, and the main method that selects one of these methods based on a command line argument is what I hope to achieve.
source share