Skip to main content

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.

Current System

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.

I wrote the existing one in VB.net forms… Not something I do very often, working mainly with web technologies like MVC,  JSON dumping Webservices and Javascript clientside to test my service code.

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.

New system

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.

Comments

Popular posts from this blog

How do you fix a roll of aluminium foil once it's started spiralling?

I had this problem.

Seen a post on Reddit.  Old one.

"This thread is archived
New comments cannot be posted and votes cannot be cast"
That is a shame.  As I now have a better answer than any of the posts.

Get a pair of tweezers and scrape down from the part of the foil roll that is "stuck".  

Don't matter if it digs down into the layer beneath.  Try to maintain even digging across the roll.

Worked a treat!

I've had a idea for Boris.

This is what he should do.

He should go to Brussels and demand:

1) End of EU commissioner/president appointments.  These should be directly elected by the Members States populations.. think "US President"-style elections.
2) Move the European Court of Justice or the European Central Bank to somewhere in the UK (not London)
3) End the monthly move of the European Parliament to Strasbourg.
4) Probably a few other things he can come up with...

THEN

Come back to the UK and offer this new deal (and Remain) or full out (with all the implications like loss of NI and subsequently Scotland) to the people in a new referendum.

Spanish verbs

Damn Spanish verbs can be frustrating.  I been trying for 13 years, and still get confused.  Must be the old brain.

I found a great "Cheat Sheet" (for fun try getting a Spanish person to say that :)) on Dummies.com but it a bit long so I cut it down a bit to just the most useful verb endings.

The cheat sheet is only good for regular verbs, and the most important/often used ones are irregular.

So last intercambio I worked with my friend to translate some typical sentences.

Here we are:


My mother was here until today,

Mi madre ha estado aqui hasta hoy,

and she will probably be back in April.

y ella a lo mejor volvera en Abril

We all had a nice time.

Nos lo pasamos bien.

Tanya & Isabel went to Barcelona on Sunday for appointments Isabel had yesterday and today.

Tanya y Isabel fueron a Barcelona dominigo para hacer encargos Isabel tenia ayer y hoy.

They are coming back now and are expected to be at home when Henry and I get there.

Ellos estan volviendo ahora mismo y se espera qu…