Thursday 26 March 2009

Creating ClickOnce Projects

It is quite easy to create ClickOnce projects. These are normal .Net projects that are built using the Publish option on the Build menu.

All the settings related to publishing a ClickOnce project are found on the Publish tab of the project properties screen.

The screen shot below shows the settings on the main screen.



The most important things to bear in mind are:
1) The publish location must be reachable from the development machine. This is the equivalent of the release folder in a normal build.
2) The install folder must be reachable from the client machines. This can be a web server or a network share (can also be a CD). You will copy the files to this location once they are published.
3) Click theUpdate button to bring up the update options screen. This is important because by default the update folder is the same as the publish folder. In reality it should be a location reachable by client machines.

The reason that the update and install locations are important, even though we will be copying the installation files to a specific location is because they are included in the application manifest and the deployment manifest.

It is possible to specify .Net Framework and certain other packages as prerequisites. However, not everything is supported here, so it may be necessary to install certain other things manually, or even edit the Publish.htm file to include links for them too.

On visiting the client site I encountered an error message "The application requires that assembly *** be installed in the Global Assembly Cache". This message related to SQL SMO.
As it happens, all the files required for SMO were already installed on these machines.

The answer is:go into the VB project properties page, publish tab, click application files.
Then for the files that will be installed separately and not updated as part of the clickonce package, change their setting from Prerequisite(Auto) to Include(Auto).





ClickOnce Deployment


This looks very promising, especially where an application does not need to deploy any files to the GAC (Global Assembly Cache). An example of .Net applications that deploy to the GAC would be those that use Microsoft Office PIAs (Primary Interop Asseblies)

However, there may be work arounds for this, such as installing PIA's separately.

This page gives a good walk through of ClickOnce deployment.

In visual studio, Build\Publish takes you to the simple publishing wizard.
When you publish, a set of folders and files is created that inclused Publish.htm.
This is the starting point for installing the ClickOnce application on the user's PC.
When choosing the local web server screen shot one shows the resulting folders\files that are created.
Opening Publish.htm gives this screen:


Click Install and this dialog follows:


As in my test scenario the application was not signed, this dialog appeared.

The application is not actually stored on the client machine. (At least not in the usual location, it is not is program files sub directory)

When an update is posted to the update location, and a user clicks on the application shortcut they will see this message. Note, the update has it's own version number system, and does not depend on the application version number.


Deploying ClickOnce Solutions On Client Sites
In the project properties\publish tab there are options that can be set that make it possible to have install and update locations that are different from the publish location.
On the main page there is an installation URL as well as a publish URL. Make the installation URL the location of the files on the client site. On the Update page, set the Update Location to the place on the client network where updates will be located. This can be the same as the publish URL.


Friday 6 March 2009

VB.Net Tracing

Use Trace is very much like Debug, but it allows you to  tracing on the client machine without visual studio.

I have created a class trace which can be used in any project, and writes basic information about the application and the user away to a config file.
This should be include in a project, and a start statement should be called during the application load.
The trace flag should be set to on in the project options.
Then anywhere in the application where I want to check a value, put Trace.WrineLine("")