A set of .NET Framework managed libraries for developing graphical user interfaces.
Hi @Encinas, Luis ,
Thank you for reaching out. Using a form while you develop is a sensible plan, since it makes the logic much easier to test and watch before it runs in the background. I'm reading "windows server" in your question as a Windows service. The key is to keep your actual logic separate from both the form and the service, so the same code runs in either place and nothing needs to be rewritten when you switch. The form itself can't become part of the service, because since Windows Vista a service runs in an isolated session and cannot interact directly with the user.
The setup looks like this:
- Create a Class Library project and put all the real work there, for example in a class with one method that starts the work and another that stops it. When choosing templates, pick the ones without "(.NET Framework)" in the name and use the same .NET version for all three projects, so they can reference each other.
- Create a Windows Forms App project that references the library. During development, use it to start, stop, and watch your logic with buttons and labels.
- When the logic is ready, create a Worker Service project that references the same library and calls the same class. The form project is not part of what you deploy.
The tutorial Create Windows Service using BackgroundService walks through step 3 in full, including sample code, the Microsoft.Extensions.Hosting.WindowsServices package, and registering the service with sc.exe. In Visual Studio, the Worker Service template appears only after the ASP.NET and web development workload is installed, so if you don't see it, that is the likely reason.
If you later want a window to check on the service after it's deployed, the form can stay as a separate app that communicates with the service, as the Interactive Services page above describes.
I hope this gives you a clear starting point for the project. If any step doesn't go as expected, share which step it is and the exact error message you see, and I'm happy to help from there.
I hope this helps clarify the available documentation and the appropriate next step. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide your insights.
Thank you.