Code

MvvmControls: Adorners

This is the first post in a series detailing the various components in my WPF open source projects. The Adorners class fist appeared on this blog back at 2010, it’s a small component that let you attach a template to a control and then open an instance of that template in an adorner. The code is on github at https://github.com/nirdobovizki/MvvmControls Usage: Create a ControlTemplate. Inside the control template use an AdornedPlaceholder element, this element will position itself right on top of the attached control and you can...

3 New WPF Open Source Libraries

I’m releasing all my WPF code as open source, this includes 3 projects: MvvmMonkey, MvvmGorilla and MvvmControl. All three libraries are released under the MIT license so you can use them anywhere including commercial projects. MvvmMonkey This is a flexible set of components, each solves a single issue with MVVM (the issue is usually a type of boilerplate code) This is a low-risk library you can use in any project, you can use any part of it with practically no impact on the rest of the code. This library is already on github at https://github.com/nirdobovizki/MvvmMonkey...

How to design an API

APIs are interfaces that let code written by other developers interact with your software – and interface code has to be designed for whoever is doing the interfacing. When you (or someone else) designs a user interface that interface has to fit the user’s worldview, it has to work like the user expects it to work and it has to make things easy for the user – user interface that is designed to show how clever you are or the be as pure and theoretically correct as possible is hard for the outside user to understand, difficult to use...

Convert SVG to XAML

I have an SVG to XAML convertor I wrote for an old project that was canceled and I was wondering if anyone needs to convert SVG graphics to WPF XAML. If you need something like that leave a comment on this post (or, if you don’t want to comment in public use the contact form), if I see activity here I’ll polish the converter a bit and release it as a product. If no one cares the convertor will remain forgotten on my hard disk until at some point in the future it will be accidently deleted (probably...

All Named Colors with Sample, RGB and Hex Values

Some times you just need to quickly look up a color hex value, or quickly check if a color is light or dark, so I made a table of all the named colors in .net (that corresponds nicely to the named colors in HTML, CSS and most other platforms). The text color in this table (black for light colors, white for dark colors) was calculated by the code from my post about the perceived darkness of colors. Color Name ...

Speed Dial Control for WPF

Speed dial controls are cool, especially if they are done right with animated dial and everything - that is why those controls are relatively popular in commercial 3rd part control packs. Speed dial controls also take a lot of screen space to show very little information, that makes them appropriate for only a tiny number of real world cases – but they are cool, so we’ll write one. WPF has a very powerful concept called “lookless controls” – the look and feel of the control is separate from the logic of the control – and...

Automatically Verify Data Bindings are correct in WPF XAML Files

This post was inspired by this stack overflow question. We C# programmers are used to our compiler (and in recent years, our code editor) catching typos and stupid mistakes long before the program runs, actually, we are used to the program not being able to run until we fix all those mistakes, if I type user.UsrId when in fact the user id is stored in user.UserId (the first example is missing an e) the editor will highlight the wrong name and the compiler will refuse to compile the code. On the other hand, WPF data bindings are just text that isn’t verified...

Easy form layout in WPF Part 3 – Adding Groups

This is the third and final post in a series, you may want to start from the beginning: Easy form layout in WPF Part 1 – Introducing FormPanel. Easy form layout in WPF Part 2 – How to deal with more complicated scenarios Easy form layout in WPF Part 3 – Adding Groups (You are here). Let’s divide the controls from out previous example into groups and produce this dialog box: Putting multiple FormPanel panels in the window, each in its own...

Easy form layout in WPF Part 2 – How to deal with more complicated scenarios

This is the 2nd post in a series, you may want to start from the beginning, this series includes: Easy form layout in WPF Part 1 – Introducing FormPanel Easy form layout in WPF Part 2 – How to deal with more complicated scenarios (You are here). Easy form layout in WPF Part 3 – Adding Groups. You can find the complete source code with a sample project at the end of the last post. In the previous post I’ve described the wonderful work saving FormPanel that can take care...

Easy form layout in WPF Part 1 – Introducing FormPanel

The WPF layout system is extremely powerful, there’s almost nothing you can’t do with Grid and maybe a few DockPanel objects – but that power comes at a price and that price is a lot of typing. I find it hard to believe that anyone who has written any form in WPF isn’t sick of  <RowDefinition Height="Auto"/> and Grid.Column=”1” Grid.Row=”1” – and of course things get worse when you have to add a new row at the beginning of the form and you have to manually update all those Grid.Row definitions. So, in this series I will try to solve the problem. Now...

Give your application the Hollywood user experience with WPF

Have you ever noticed the completely ridicules UI of computers in movies and TV shows? You rarely see any windowing systems (but that’s ok, the hero never has to switch windows), the fonts and icons are huge (also ok, there’s never anything more complex than 3 text boxes and 2 buttons) except for lists that always display in a grid with 2 points font size (also ok, the hero never needs more than a second to scan the entire list). But it sure is dramatic, logging into a secure system looks like opening a...

WPF Adorners Part 4 – Simple and Powerful System for Using Adorners

This is Part 4 of a series, you may want to read part 1, part 2 and part 3 first. In the previous post I promised a cool-looking popup – so we’ll start with the screenshots and follow with the code to create them. We start with the same window-with-a-button we used in the first post in the series: But when we click the button we get a speech bubble popup! How did we do that? First, let’s look at the Window.xaml file: <Window x:Class="AdornerDemo.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:a="clr-namespace:AdornerDemo" Title="Window1" Height="300" Width="300"> ...

WPF Adorners Part 3 – Adorners and Validation

This is part 3 of a series, you may want to read part 1 and part 2 first. Before we continue let’s take a quick look at WPF validation. Let’s add a property to our window class that will just not validate: public Window1() { DataContext = this; InitializeComponent(); } public string BadProperty { get { return "Bad"; } set { throw new Exception("Value must be \"Bad\""); } } And bind to this property: <TextBox VerticalAlignment="Center" HorizontalAlignment="Center" Width="150" > <TextBox.Text> <Binding Path="BadProperty" UpdateSourceTrigger="PropertyChanged"> ...

WPF Adorners Part 2 – Placing any control on the adorner layer

This is part 2 of a series you may want to read part 1 first. In the previous post in this series we created a trivial adorner and placed it over a button – in this post we will look at placing something more complex inside an adorner. We’ve already seen Adroner is a FrameworkElement and we know FrameworkElement can contain other visuals inside it – so let’s just write an adorner that contains a control: using System; using System.Windows.Documents; using System.Windows.Controls; using System.Windows; using System.Windows.Media; namespace AdornerDemo { class ControlAdorner : Adorner { private Control...

WPF Adorners Part 1 – What are adorners

WPF adorners are visuals that live in their own layer above the normal controls, they were originally designed to support adding notes inside the document viewer (that is why they’re in the System.Windows.Documents namespace) but they can be useful in many other situations. In this series we will look at some ways to use adorners in an application and I will introduce a simple system to simplify the use of adorners. Before we begin let’s look at a simple example: We will create an adorner that draws four red boxes at it’s four corners: using System; using System.Windows.Documents; using System.Windows.Media; using System.Windows; namespace AdornerDemo { class...

.net DateTime Format Strings Cheat Sheet

I wrote a two page “cheat sheet” that covers all the .net DateTime format strings (one page for standard format strings and one for custom format strings). This sheet shows shows the result of the format strings in four cultures: English US, English GB, Spain and France. I hope that this will remind developers how different the date and time format even in languages that are relatively close to English. Download .net DateTime Format Strings Cheat Sheet, latest version, PDF format And remember to pass a CultureInfo object to DateTime.ToString and DateTime.Parse, read The Single Most...

WPF Printing Part 4 – Print Preview

This is the 4th post in a series about printing in WPF, you may want to take a look at the previous posts about printing WPF visuals, using FixedDocument objects and WPF pixel sizes. There are many ways to print in WPF, in this series I’m constructing FixedDocument objects and then print them, at first it may look like there are easier or more powerful ways to print – until you need a to the print preview feature. WPF has a DocumentViewer control that can display a FixedDocument on the screen with paging, panning, zooming and a print button – exactly everything...

What Percentage of Users have the .net Framework Installed (and what versions)

When I read forums used by software developers I often see people saying they can’t use .net (or some feature of .net) in their product because .net is a huge download, from my experience installing .net from the setup program of your own software is really not a big deal but I wanted to see the real numbers for .net installations. The numbers are based on visits to this site from mid December (when I installed a new analytics software that let me get this number) until mid April (when I wrote this blog post), because I regularly blog about WPF...

Free Mouse Pointer Image

Here is a free mouse pointer image you can use whenever you want, for example you can add it to a screenshot to show someone where to click. The image is slightly larger than a real mouse cursor, isn’t completely white and has a large drop shadow – all of those make it much more noticeable when copying it into a screenshot. You are completely free to use this image wherever and however you like, you don’t have to give credit (but a link back will be very appreciated). The image is a PNG with transparent background, just right click and select...

WPF Printing Part 3 – Sizes

In the previous post in the WPF printing series I used a lot of numbers for sizes and positioning, I want to take this post to explain those sizes. Unlike WinForms where each pixel is really a device pixel in WPF each “pixel” is actually 1/96 of an inch, this means that most of the time each WPF pixel is one pixel on today’s screens (that are usually 96DPI). For printing this means that when you specify a “pixel” size in WPF this will always translate to the same size on paper, regardless of the actual printer you...

WPF Printing Part 2 – The Fixed Document

This is part 2 of a series about printing in WPF, in the previous part we printed the content of a WPF visual, in this part we’ll create and print a fixed document, in the end of the previous post I wrote well deal with choosing printers and setting up print settings – but actually printing is more interested and I’ll get to printer management later in this series. Printing a FixedDocument is the simplest way to do some “real” printing with control over paging, margin and everything else. The code is much longer than the examples in the previous post but...

WPF Printing Part 1 – Printing Visuals

This is the first part of a series of posts about printing in WPF starting from printing a single element and going all the way to advanced topics like background printing and XPS. We will start this series with absolutely the simplest WPF application that prints something, we will create a window with a single button – and we will then print this button. The gateway into the WPF printing system is the System.Windows.Controls.PrintDialog class, this class manages printer settings and let you do the actual printing, it is also, as the name suggests, the print dialog – but you don’t have...

Getting a WPF application to pick up the correct regional settings

Before we begin, the way a program gets its settings is both complicated and outside the scope of this blog post, when you test functionality related to settings change it’s important you start the program directly from a folder window, if you run it from within Visual Studio or any other program you may get incorrect results. First let’s see the problem - open Visual Studio and create a new “Wpf application” project Change Window1 code to: public partial class Window1 : Window { public Window1() { InitializeComponent(); ...

A way to use triggers anywhere in WPF

The biggest limitation of triggers in WPF is that except for EventTrigger they only work in styles and templates, I always find myself in situation where just putting a trigger directly in my window or control class will save me a lot of work – but it just can’t be done. Just a few days ago I accidently run across a simple workaround, this is probably the best kept secret in WPF and is hidden in a little blue box at the end of this post on animation in M-V-VM. Just define a DataTemplate with whatever you want to show and your...

WPF Data Binding Cheat Sheet Update - The Internationalization Fix

UPDATE: I wrote a more in dept post about getting Wpf to pick up regional settings and even update them on the fly There is a new version of the WPF Data Binding Cheat Sheet, there is a small block of code you have to add to any WPF application in order to correctly format dates and numbers using data binding (I define “correct” as what the user would expect), read on for the full details and the required code for your copy-paste pleasure. By default, when you use data binding and the target property is a string, WPF will format your...

Blurred Images in WPF

Bitmaps and icons displayed using WPF often have a very annoying blur effect caused by WPF trying to draw the image with sub pixel precision. Let’s take the following image: The image is diaplyed in the WPF window using this XAML: <Image Source="blurexample.png" Stretch="None" Margin="5.0" VerticalAlignment="Top" HorizontalAlignment="Left"/> But if we set it’s margin to 5.5 pixels (or place the image after something that can take non-integral number of pixels to draw, like text) we get this: That is obviously unacceptable, but how can we overcome this? The best solution I’ve found is the Bitmap class described in this post. But the bitmap class has one limitation making...

Lambda in XAML

Here are links to a 3 part series with code that let you use C#-like lambda expressions in XAML instead of writing value converters. For example, instead of writing a value converter that takes a DateTime and calls ToShortTimeString you can write: <TextBlock Text='{Binding Source={x:Static s:DateTime.Now}, Converter={fix:Lambda "dt=>dt.ToShortTimeString()"}}'> WPFix Part 1 (Lambda Converter Extension) WPFix Part 2 (Binding Extension) WPFix Part 3 (Extension Methods)

Custom Chrome (window frame) with WPF

This post on the WPF SDK blog contains almost everything you need to know to change your window appearance using WPF, this includes: Extending Vista glass effects into your window. Maximizing a window with WindowStyle of None without covering the taskbar. Removing information from the application title bar (Vista only). Drawing in the window title area in a way that is compatible with Vista glass effect. A must read for every WPF developer.

Vista style open and save dialogs with WPF (without using the Vista bridge sample)

This is the fourth (and last) part in a series about how to get the latest look and feel for your WPF application, the previous parts are: Why am I Getting Old Style File Dialogs and Message Boxes with WPF Will Setting a Manifest Solve My WPF Message Box Style Problems? The Application Manifest Needed for XP and Vista Style File Dialogs and Message Boxes with WPF In part 3 of this series we’ve set a manifest file and almost solved our problem – we finally got rid of...

The Application Manifest Needed for XP and Vista Style File Dialogs and Message Boxes with WPF

This is the third post in a series about how to get the latest look and feel for your WPF application, the first part is here and the second is here. Here is the manifest file needed to get the newer version of the common controls library, just setting this manifest will get us the newer (XP or Vista) look for message boxes and the XP look for the file open and close dialogs – but when running on Vista this will not give us the Vista style open and close dialogs, I’ll show how to fix this in the next...

Will Setting a Manifest Solve My WPF Message Box Style Problems?

This is the second post in a series about how to get the latest look and feel for the message boxes and common dialogs in your WPF application, In the first post I described the problem. I just understood from a reply I got that I wasn’t clear enough about all the little details in the previous post, I hope this will clarify everything a bit: This approach works, I know because I tested it myself, it works on XP SP2 and on Vista RTM, I didn’t test it on a 64bit Windows yet but I hope to...

Why am I Getting Old Style File Dialogs and Message Boxes with WPF

This is the first post in a series about how to get the latest look and feel for the message boxes and common dialogs in your WPF application. You wrote your WPF based software, your user interface looks great but the moment you display a message box or a file open/save dialog what pops up is a Windows 2000 style dialog. For example, I’ve created a WPF application with two buttons on the main window, as you can see from the image below the application picked up the XP style with the rounded buttons and everything. Let’s click the “Message Box” button, the...

WPF: Problems with Keyboard Focus When Using Validation

If you use WPF’s data binding with validation a red border appears around controls with invalid values, you can also use the Validation.ErrorTemplate attached property to get a better look for the invalid controls. But – if you try this you’ll discover that there’s a new tab stop on you from, the red frame (or your own template) now accepts focus, breaking tab navigation. The problem is that that the validation framework will add a control to the adorner layer in order to display the error indicator – and this control is focusable. To fix it just add the following to the Window’s...

Simple Software Isn't

Creating good software is a very complicated, even in a small project there are hundreds if not thousands of little details you have to get right and it's easy, not to say tempting, to reflect this complexity in the user interface. High end "enterprise" software is actually expected to look and feel very complex, otherwise how can you justify the amount of money you spent on it. The concept of simplicity is very popular right now in the software development world, and someone who hasn't worked on "simple" software before might think simplicity is about doing less, or making the code simpler,...

Calculating the Perceived Brightness of a Color

I needed a way to test if a background color is light or dark in order to choose an appropriate text color (black on light colors and white on dark colors), you can find yourself in the same problem if you try to convert an image to grayscale. I found many approaches that didn’t work well, I’ll describe them and the problems I discovered below – but first – the successful solution. I finally found a solution that actually works on this web page the formula is: brightness  =  sqrt( .241 R2 + .691 G2 + .068 B2 ) Or, in C# using the...

Setting the Selection Color for a list box item in WPF

WPF’s styling and templating support is amazing, but some controls are easier to template then others, one of the least intuitive to style controls is the ListBox, it’s very difficult to change the ListBoxItem selection background color for example. Here is a post on the WPF SDK blog that explains how to do it. I’ve posted this here so I’ll know where to look the next time I want to style a list box

WPF Reflection Control

One of the more popular eye-candy effects is reflection, and WPF can do really good reflections, this post on Xamlog shows a really nice technique to add reflection to just about anything. When I was showing this technique to a co-worker he asked me if it can be encapsulated in a control, well, why not? So I quickly wrote this control, the control is a "Decorator" like a Border, that means you can add one child to it and it draws itself around that child (obviously this child can be a panel with multiple children). This control is divided into two halves...

WPF Image Viewer Part 7, Rotating the Image with a Transform and More Data Binding Between Controls

This is the final part of the WPF image viewer tutorial: Introduction, Part 1, Part2, Part 3, Part 4, Part 5 and Part 6. So, what are transforms? This is an extremely short and simplified explanation, like most of the topics I cover in this tutorial you can use this to get started but if you want in-depth information I suggest you but this book. Transforms are a way to modify how something is rendered to the screen, you can take any control and use transforms to move it, scale it, stretch it, rotate it and more. There are two ways to apply a transform in WPF, Render...

Null Argument Exception When Printing to the Microsoft XPS Document Writer

I have a problem with printing in WPF, it happens consistently on my main development machine but I haven’t been able to reproduce it anywhere else. And I have a solution.

WPF Image Viewer Part 6, Binding to Current List Item

This is a part of the WPF image viewer tutorial: Introduction, Part 1, Part2, Part 3, Part 4 and Part 5. In this post were going to replace the big blue area in the center of our window with an image, obviously the image we want is the selected thumbnail from the list box to the left. First let's replace the blue rectangle with an image control, then we'll figure out how to get the image into it, just replace the second rectangle in the XAML file with an <Image/> element. Now let's play with data binding, WPF has very nice support for binding...

WPF Image Viewer Part 5, Panels

This is a part of the WPF image viewer tutorial: Introduction, Part 1, Part2, Part 3 and Part 4. In this part where going to organize our application layout, currently our entire application window just contains a list box full of images, it was easier to do then with WinForms but that doesn't make it very useful. The WPF controls that can contain multiple children and arrange them are called panels, WPF has several useful panels we can use, in this post we'll use the StackPanel and DockPanel panels. StackPanel The StackPanel is probably the simplest panel in WPF, it just arranges all its children...

WPF Image Viewer Part 4, Data Templates and Resources

This is a part of the WPF image viewer tutorial: Introduction, Part 1, Part2 and Part 3. I promised something nice and we got all the way to the 4th post with a program that displays a list of filenames, it's time to start seeing some images. The WPF list box control isn't the old Windows list box, while the old list box could only display a list of strings the WPF list box can display any list, if we tried to display buttons we would have got a list of completely functional buttons you can press – but we used a list...

WPF Image Viewer Part 3, Data Binding to a List Box

This is a part of the WPF image viewer tutorial: Introduction, Part 1, Part2. In this part we'll connect the C# code with the XAML UI, just open Window1.xaml, find the Grid element and add the following line between <Grid> and </Grid> <ListBox ItemsSource="{Binding AllImages}"/> This will create a list box and bind it's ItemsSource property to the AllImages property we wrote in the last part, it you'll run this you will get a window with a list box covering the entire window and the list box showing the names of all the image files. The reason we set the DataContext in the...

WPF Image Viewer Tutorial Part 2, The C# Code To Load Images

This is a part of the WPF image viewer tutorial: Introduction, Part 1. This part of the tutorial has very little to do with Wpf, we just have to define and fill the data structure used to hold the image information. First let's define a class to hold an image and it's file name, I've defined this class as a nested class of Window1 because it doesn't matter where we put it. public class MyImage {    private ImageSource _image;    private string _name;    public MyImage(ImageSource image, string name)    {       _image = image;       _name = name;    }    public override string ToString()    {       return _name;    }    public ImageSource Image    {       get { return _image; }    }    public string Name    {       get { return _name;...

WPF Image Viewer Tutorial Part 1, XAML Basics

This is part of the WPF image viewer tutorial series, you can read the introduction here. Create the project We'll start writing code soon, but first a short overview of what visual studio does for us. After you installed all the required software you can start Visual Studio Select File -> New -> Project From the main menu. In the project types tree (on the left) select "Visual C#" and on the templates list (on the right) select "Windows Application (WPF)". Enter "ImageViewerTutorial" into the name box at the bottom and click Ok Visual Studio should now create a skeleton WPF application for you. Visual Studio created 2...

WPF Tutorial - A Cool Image Viewer

I just love WPF, it's the best UI system I've ever worked with. When I want to introduce my friend to WPF I just build a small image viewer with them, it takes me less than 30 minutes and it really shows the power of WPF features like templates and data binding. I've decided to expand my little demo and post it to my blog, this will take several posts – each one showing another nice feature. Before we begin there are a few things we need in order to write WPF code: Windows XP SP2 or Windows Vista –...

How To Write an Automatic Update System Part 8 – Alternatives

Finally, the last post in the auto-update series. Previous posts: part 1, 2, 3, 4, 5, 6 and 7 For 8 posts I've been writing about the technical details of building a good automatic update component from scratch, what I haven't wrote is that it's probably silly to write your own instead of using something that already works. ClickOnce ClickOnce is built into .net (version 2.0 and later) and is extremely easy to use, all you have to install your software using ClickOnce. You prepare the ClickOnce package – just a few files on a web server (all your program files and...

How To Write an Automatic Update System Part 7 – Updating the application while it's running and reverting to previous versions

This is part 7 of a series, previous posts: part 1, 2, 3, 4, 5 and 6 In the previous part I promised to talk about how to update a program while it's running, if you were hoping for some cool file system locking trick you are going to be disappointed. The method I used for yaTimer, the time tracking application I've developed, is very simple. All the program files are not stored directly in the program folder but in a sub-folder this sub-folder is different for each version, so what you get is: Program Files    yaTimer       1.1.0 all the files for version 1.1.0 And...

Passing Wpf Objects Between Threads (With Source Code)

When working on yaTImer's new report engine I got myself into a bit of a problem, I'm blogging about it because I couldn't find an answer on the web and I can't believe I'm the only one with this problem, so I hope someone will find my solution helpful (or maybe suggest a better one). My reports engine generates a FixedDocument that I can print or show to the user, because the report can contain a lot of information generating the document can potentially take some time, so I went for the easy solution and dropped a BackgroundWorker into the code. So...

How To Write an Automatic Update System Part 6 – The Update Process User Interface

This is part 6 of a series, previous posts: part 1, 2, 3, 4 and 5 In the end of the previous post in the series I wrote this part will be about updating the program while it's running and updating the service itself, this will wait until the next post because there is a small limitation to our auto-update service I didn't talk about – you can't interact with the user from a Windows service. Showing user interface from a service has been "not recommended" for a long time and disabled by default – but it takes just one checkbox to...

How To Write an Automatic Update System Part 5 – Working as a Limited User and Under Vista

This is part 5 of a series, previous posts: part 1, 2, 3 and 4 In the previous part we finally got our auto-update system working, the only problem is that it only works if we have administrator rights, I find this totally unacceptable (it also doesn't work at all under vista). The standard solutions is relatively simple, have a second component on the user's system that runs with sufficient privileges and let it do the actual updating, another approach is to prompt the user for the administrator name and password and use them to run a setup program with administrator rights,...

The Single Most Important Internationalization Tip

This post may be news to developers in the US but I (like most of the people in the world) have lived all my life on the wrong side of incorrect internationalization/localization efforts – so you can trust me on this. This post is written from a .net perspective, but it can be easily translated to any other environment. And the big tip is: respect the user preference, remember it may be different (or, in technical terms CurrentCulture, InvariantCulture). Respect the user preference - every string that is displayed to the user or entered by the user should be...

How To Write an Automatic Update System Part 4 – Downloading and Installing

This is part 4 of a series, previous posts: part 1, part 2 and part 3. After we got the download details in the previous post it's time to download the update. yaTimer - The software I'm selling, and obviously the easiest way to track your time - is a small application with small updates, so it just uses the .net WebClient class to download the file from the server, it's simple and easy to write the code and we can move on. On the other hand, if your application needs to download large files of the web you will soon discover the...

How To Write an Automatic Update System Part 3 – Finding The Update

This is part 3 of a series, previous posts: part 1 ,part 2. In part 1 I presented a quick hack of an auto-update feature, In this part I'll describe a real auto-update component, and one that can be implemented very quickly. The first thing our auto-update component has to do is detect when an update is available, since we don't have much time to implement this feature (we have a lot of other more visible features we want to finish for this version of the software), we will take the easiest option possible – store a small file on the web...

How To Write an Automatic Update System Part 2 – Security Considerations

This is part 2 of the series, part 1 is here. Before describing how an auto-update feature might work I wanted to talk a bit about security, an auto update feature by definition downloads and runs program from the internet, your users trust you that your auto-update mechanism will only download and install updates to your software – don't abuse this trust. The internet is a dangerous place, the bad guys might find a way to modify your web site – or to completely hijack it, when your program downloads updates it has to be 100% sure those updates are from you...

Source Code for How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever

Here is the C# source code for the previous blog post How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever this code is for .net version 2.0 or 3.0 try {    System.Diagnostics.Process.Start("http://www.example.com/upgrade_from_version_1.htm"); } catch {    // ignore exception, might be FireFox’s fault } Just let the system do the heavy lifting, it will automatically find the default browser for you and load the web page. The try-catch is needed, some versions of FireFox will not handle this correctly and cause an exception (as well as an error message) – but it will still load the web page after throwing the exception. Note that...

How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever

You are working on finishing the first version of your software product, you want to release it as soon as possible, you already decided to delay some features to the next version and you don't have the time to write an automatic update feature or to buy and integrate an existing solution. What do you do? You just add a page to your web site, the page just says there is no update available, in your application the "check for updates" button or menu item just opens that page in the user's default browser. When a new version is available -...