Basic WinForm Application Deployment

I recently completed a .NET WinForm project for one of our clients, a parts management and bill of materials system. Having spent many years doing ASP and ASP.NET web applications, I found many aspects of the WinForm application appealing: application speed, state management, printing, and just overall better control of the client application and the user’s experience.

However, WinForm apps have a major drawback when compared to web applications: deployment. When there is an update to a WinForm app, it needs to be distributed to all the desktops that are running it. Depending on the size of the organization, this can be a daunting task.

So I spent some time tonight playing around with a “self-deploying” and “self-updating” application and found that it’s pretty easy (even without using the Microsoft Updater Application Block).

Here’s the basic setup:

1) A WinForm application compiled as a DLL. You can do this in VS.NET under the project properties, General, Output Type, Class Library.

2) A web service running on IIS. This will provide the information on which files the client needs as well as the files themselves.

3) A “wrapper” application which retrieves the client information and files from the web service and executes the application.

First, our client application. I’ll skip the code here and just give you the basic details. We have a sample “Business Objects” assembly with a GetHelloWorld method and a WinForm app compiled as a DLL. This has a form with a button that calls the method on the business object. I did this so we’d have two DLLs that we would need to download for this sample.

Let’s take a look at the Web Service. It consists of a SmartClientDefinition class and a
GetSmartClientDefinition method.

View SmartClientDefinition class

Our GetSmartClientDefinition method just returns the information needed by the client: which files to download, which assembly to load and which instance to create.

View GetSmartClientDefinition method

Our wrapper application is just an EXE that calls the web service, downloads the assemblies, loads up the main assembly and instantiates an instance of our HelloWorld form.

View SmartClientWrapper class

To deploy our hello world app, all you need to do is put the DLLs on the web server in the same folder as the web service and distribute the EXE to your desktops. When it runs, it calls the web service, gets the files and runs the WinForm application. When you need to update all the desktops, all you need to do is copy the updated DLLs to the web server and they will be deployed the user runs the app.

Keep in mind that this sample is very basic and doesn’t support a lot of the functionality that is built into the Microsoft’s Updater Application Block, which will handle pretty much any deployment scenario you can think of. This is just to give you an idea of how you can roll your own deployment/update scenario if need arises.

You can download the sample code here.

Rita had a change of plans

She’s still pushing farther off to the east and our forecast for tomorrow looks like this:

A 20 percent chance of showers and thunderstorms. Mostly cloudy, with a high around 92. North northwest wind around 20 mph.

People are still panicking though. The three gas stations I passed on the way home from work yesterday were out of gas. A friend’s wife reported that their local grocery store was completely out of meat. Again, the stupidity of some people amazes me.

Our forecast is a whole lot better than what were expecting as of Wednesday, so it looks like we’re in good shape. If we get anything interesting, I’ll get some video.

Rita, Thursday Afternoon

The latest NOAA updates on Mrs. Rita have been posted and it’s looking much better for Austin. She’s tracking more to the east now and we’re only forecast to get 20mph winds along with rain and thunderstorms. It even looks like Houston is going to get the weaker west side of the storm instead of a head-on blast.

Hopefully it’ll stay this way and it’ll be an uneventful wet weekend in Austin.

Shopping Before the Storm

Just got back from the grocery store here in Austin. That was THE busiest I’ve ever seen it. The checker said it’s been a madhouse since 11am.

We were just doing our normal weekly shopping and only picked up a few extra canned and dry goods. The following items were completely gone: bread, bottled water, eggs, bananas, eggs, C and D batteries, and of all things, lettuce. Figure that one out. I also noticed that the following were well picked over and getting low: any canned food (especially soup), milk, crackers, soda, peanut butter and bleach.

It’s curious watching the semi-panic of some folks. The people in front of us had a lot of canned food, plus a LOT of caffeinated soda, which would be the last thing I’d want to drink in an emergency. Caffeine will dehydrate you, putting you in an even worse situation. Surprisingly, I still saw a lot of Gatorade and similar sports drinks on the shelves. My wife saw one guy that had five packs of cheese.

It’s also curious to watch the complete oblivion of other folks. One guy had three large cartons of ice cream in his cart. Now, seeing that we’re expected to have widespread power outages, frozen food would not be a wise thing to buy right now. We put off all our frozen food purchases until next week.

Unfortunately, I would like to have picked up some C-cell batteries for one of our Mag Lites, but they were all out. We have plenty of D-cell and AAA, so it’s only a minor issue.

The latest NOAA update has moved Rita’s track further to the east, so hopefully it’ll lessen the impact in Austin. We’re still forecast to get 45-50mph winds gusting to 70mph.

Rita’s Coming to Visit

I am a hurricane news junkie.

However, it’s for good reason. We’re located in Austin, Texas and current reports show that Hurricane Rita will be passing nearby. The National Weather Service is currently forecasting 45-50mph winds gusting to 70mph. While not hurricane force yet, it’s nothing to sneeze at.

Because of this, I’ve been watching the news and .gov weather sites for hurricane updates. All day. Tabbing between writing code and refreshing images and reports. It’s getting a bit distracting. Katrina was doing the same thing to me. I’m trying to cut back.

I started stocking up on non-perishable food and water after Katrina stopped in on New Orleans. At the time it wasn’t urgent, so I’d pick up a little bit here and there. Now with the possibility of lengthy power outages, the need is a bit more pressing. We’ll be hitting the store tonight to pad our supplies. I wanted to have at least seven days worth of supplies and we’re sitting around five right now.

Anyway, back to coding….