Skip to main content

Microsoft Silverlight

Answered Question update your app demo conks outRSS Feed

(0)

dr d b karron
dr d b k...

Member

Member

60 points

113 Posts

update your app demo conks out

Dear Silverlighters and Visual Studioer;

 

I am seized with the idea that I can put a button on my app to

1) ask the user if they want to install it out of browser

2) figger out if your running alone without the network/server

3) figger out of your app is out of date.

 

My questions are

 

1)Can I reclaim the right mouse from silverlight ?Confused

2) can I put a 'update' app on my ap and how does it determine if it is out of date ?

I assume that this is only for out of browser and disconnected apps ?

I'm mainly interested in having a continuous release process, where we change the code under the client all the time.

If it breaks, they can let us know and revert to a previous version or update to a later version if they have been operating out of browser.

How can I recover the build date/time programatically and define major and minor releases ?

Can a live app get out of date relative to the production server ? It the code always updated or if

someone hangs out in the cliend for days on end can they become out of date relative to the server ?

 

3) I built the sample app (see, i'm learning) but it conks out in run time on the C# code at app.Install();

 

Here is the code and it conkes out at app.install() on line

A first chance exception of type 'System.Exception' occurred in System.Windows.dll

An exception of type 'System.Exception' occurred in System.Windows.dll but was not handled in user code

Additional information: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

 

it conks out on line 60, app.Install() inside a try {} catch () {} block;

But apparently the catch misses ...

 

 

1    using System;
2    using System.Net.NetworkInformation;
3    using System.Windows;
4    using System.Windows.Controls;
5    
6    namespace OutOfBrowser
7    {
8        public partial class MainPage : UserControl
9        {
10           Application app = Application.Current;
11           public MainPage()
12           {
13               InitializeComponent();
14               LayoutRoot.DataContext = Deployment.Current.OutOfBrowserSettings;
15               UpdateUI();
16               app.CheckAndDownloadUpdateCompleted += 
17                   App_CheckAndDownloadUpdateCompleted;
18               app.InstallStateChanged += (s,e) => UpdateUI();
19               NetworkChange.NetworkAddressChanged += 
20                   (s, e) => UpdateNetworkIndicator();
21           }
22   
23           private void UpdateUI()
24           {
25               UpdateNetworkIndicator();
26   
27               installButton.Visibility =
28                   app.InstallState == InstallState.NotInstalled ?
29                   Visibility.Visible : Visibility.Collapsed;
30   
31               updateButton.Visibility =
32                   app.IsRunningOutOfBrowser ? 
33                   Visibility.Visible : Visibility.Collapsed;
34   
35               isRunningOutOfBrowserTextBlock.Text = 
36                   app.IsRunningOutOfBrowser.ToString();
37   
38               installStateTextBlock.Text = app.InstallState.ToString();
39           }
40   
41           private void UpdateNetworkIndicator()
42           {
43               networkIndicator.Visibility =
44                   app.IsRunningOutOfBrowser ?
45                   Visibility.Visible : Visibility.Collapsed;
46   
47               bool online = NetworkInterface.GetIsNetworkAvailable();
48   
49               networkIndicator.Text = online ?
50                   "ONLINE" : "OFFLINE";
51   
52               updateButton.Visibility = online ?
53                   Visibility.Visible : Visibility.Collapsed;
54           }
55   
56           private void installButton_Click(object sender, RoutedEventArgs e)
57           {
58               try
59               {
60                   app.Install();
61               }
62               catch (InvalidOperationException)
63               {
64                   MessageBox.Show("The application is already installed.");
65               }
66           }
67   
68           private void updateButton_Click(object sender, RoutedEventArgs e)
69           {
70               app.CheckAndDownloadUpdateAsync();
71           }
72   
73           private void App_CheckAndDownloadUpdateCompleted(object sender,
74               CheckAndDownloadUpdateCompletedEventArgs e)
75           {
76               if (e.UpdateAvailable)
77               {
78                   MessageBox.Show("An application update has been downloaded. " +
79                       "Restart the application to run the new version.");
80               }
81               else if (e.Error != null && 
82                   e.Error is PlatformNotSupportedException)
83               {
84                   MessageBox.Show("An application update is available, " +
85                       "but it requires a new version of Silverlight. " +
86                       "Visit the application home page to upgrade.");
87               }
88               else
89               {
90                   MessageBox.Show("There is no update available.");
91               }
92           }
93   
94       }
95   }
 

 

dr d b karron
karron@casi.net
http://www.casi.net/
-----
I will mark your response as an answer after i test it. I have not forgotten your post !
------

prujohn
prujohn

Contributor

Contributor

3567 points

703 Posts

Answered Question

Re: update your app demo conks out

Regarding #1:

No right-mouse support in Silverlight natively.  This is by design, because Microsoft wants Silverlight to conform to browser conventions, and to support cross-platform scenarios (Macintosh users with single mouse button). 

Regarding #2:

I believe the update occurs with a simple datetime comparison of the OOB xap with the online xap.  In other words, if the online is newer, then the update occurs.  I haven't played with this much, so someone else may have a more accurate response.

Regarding #3:

Your try/catch is only catching a specific Type of exception.

use the base exception type like so "catch (Exception e)"  so that you catch any exception, and can inspect it in e.Message

After you understand better what exception Type is being thrown, you can make the catch more specfic again.

 

dr d b karron
dr d b k...

Member

Member

60 points

113 Posts

Re: Re: update your app demo conks out

i guess i need a bigger catch mitt... dB

dr d b karron
karron@casi.net
http://www.casi.net/
-----
I will mark your response as an answer after i test it. I have not forgotten your post !
------
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities