Monday, November 8, 2010

Location of ClickOnce Installation Files

C:\Documents and Settings\USERNAME\Local Settings\Apps\2.0

Friday, November 5, 2010

Show or hide file extensions

A file name extension is a set of characters added to the end of a file name that determine which program should open it. Follow these steps to choose whether Windows displays these file extensions.

  1. Open Folder Options by clicking the Start button Picture of the Start button, clicking Control Panel, clicking Appearance and Personalization, and then clicking Folder Options.

  2. Click the View tab, and then, under Advanced settings, do one of the following:

    • To hide file extensions, select the Hide extensions for known file types check box, and then click OK.

    • To display file extensions, clear the Hide extensions for known file types check box, and then click OK

Reference in the manifest does not match the identity of the downloaded assembly

If you try to reference an executable or a project with an executable you get an error when you try to update the application via ClickOnce.
The errror I got was:
"Reference in the manifest does not match the identity of the downloaded assembly"
The fix was found here:
And below are the steps:

I have test it with Visual Studio 2008 RTM, it works well now. The following steps are my test procedures.

1. Create a solution with two Windows Application projects, WinAppA and WinAppB.

2. Set WinAppA as publish project and add a reference to the WinAppB.

3. Open WinAppB properties window.

4. Click Signing tab, sign the ClickOnce manifests.

5. Click Security tab, enable the ClickOnce security settings.

6. Publish the WinAppA, publish well.

7. Test published WinAppA, it works well.



Bitmaps in WPF, disposing of bitmaps in WPF and other issues

The first thing is in WPF you can't set the Source of an Image Control to that of a Bitmap, you need to use the BitmapImage
This gives you a build error:
Image I = new Image(@"C:\Users\Public\Pictures\Sample Pictures\Penguins.bmp");
Imagecontrol.Image.Source = I
But this works:
Image I = new Image();
BitmapImage bi = new BitmapImage();
bi.UriSource = new Uri(@"C:\Users\Public\Pictures\Sample Pictures\Penguins.bmp", UriKind.Absolute);
Imagecontrol.Image.Source  = bi;
The problem with the above code is that whenever I used it and subsequently tried to delete the file Penguins.jpg or move it, I got an exception.  It seems like we were holding a lock on the file.  So the fix was to do the following:

      Imagecontrol.Image.Source = LoadImage(@"C:\Users\Public\Pictures\Sample Pictures\Penguins.bmp");

      private BitmapImage LoadImage(string myImageFile)
            BitmapImage myRetVal = null;
            if (myImageFile != null)
                BitmapImage image = new BitmapImage();
                using (FileStream stream = File.OpenRead(myImageFile))
                    image.CacheOption = BitmapCacheOption.OnLoad;
                    image.StreamSource = stream;
                myRetVal = image;
            return myRetVal;