How to deploy a standalone .net forms website as an application
The Story (for coders only)…
I need an application to manage background services on a website I run.
These services are still in debug/development mode so I create them as Windows Forms applications rather than true “windows services”.
This works well as I can breakdown the tasks and build single applications to do e.g. clean up tasks or schedule Tweets with them.
Each application has a thread, and if one is misbehaving it doesn’t take down the whole system. I can Debug/Step through applications in Visual Studio and see where they going wrong, then restart them easily enough.
So I currently have an “Orchestrator” application that controls all these background service apps.
The server is set to autologin using sysinternals autologon. Then I add a scheduled task to fire up this Orchestrator application.
The Orchestrator then queries the server to see the runstate of each application in it’s list. If one is not running it will fire up the background service. I can easily change the required state in the Orchestrator and if one if running it will kill it.
It is a bit of pig. It doesn’t use a database (I didn’t want a runaway DB from breaking my application), so all the config is stored in a JSON file - which is cool, but the datagrid is a pain and I’d much prefer to work with ashx-es.
Just for fun here is the old Orchestrator application screen shot.
The background services are in the DGV labelled 1. When I click on a row the application’s details appear in 2. Logging for the currently viewed application in Listbox 3 (this is transmitted to the Orchestrator via UDP)
Label 4 shows the Launching/Killing activity of the application and the controls in 5 allow me to configure the running properties of each background service.
I want to control the application using a webbrowser and build the GUI using web technologies not all this VB forms stuff I’m not familiar with.
But how to do that! After a lot of searching around and wild good chases I found this article about Cassini. I’m not that bothered about Framework 4.0, it is only going to run on my server, and I can send a keep-alive pulse to prevent it going to sleep – permanently.
So here is how to deploy a standalone .net forms website as an application.
Create a Forms application targetting .net version 4
Then create a new web project in the solution explorer
Add a start index.aspx page.
Search Nuget for CassiniDev-AnyCPU.dll
Install it into the Form application
In the form application add the Imports CassiniDev statement then put the following code
Change the path to the path of the website project you added. In my case it was \OrchestratorWebManager
You will need to build the website so it functions when you run the solution.
Run the Form application and there you go!
So… now the fun part.. migrating useable code from the old application to this new very basic forms project and the internal website.
Post a Comment