Silverlight OOB Application Deployment ? Concerns and its resolution

Deploying Silverlight out of browser application is not that easy. There are several constraints. But you can achieve

 

it without compromising the functionalities in your application.

 

In a normal scenario, the deployment of a Silverlight OOB is quite straight forward. But, you may face several issues

 

if your application is a bit complex. Recently, I deployed an application which had the following features.

•    Directory and file access (Read and write)

•    The Shell Execute command

•    Open Exe’s from the local system

•    Shutdown the computer – Shell Execute

All the above features required the application to run with elevated trust when running outside the browser!


This application needs to be updated automatically during the first run!

 

To achieve this, you may write the fllowing code!

 

private void CheckForUpdates()

{

    if (App.Current.IsRunningOutOfBrowser)

        {

        Application.Current.CheckAndDownloadUpdateCompleted += this.OnCheckAndDownloadUpdateCompleted;

                Application.Current.CheckAndDownloadUpdateAsync();

        }

}

 

private void OnCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)

{

    if (e.UpdateAvailable)

    {

        // Update available and the application is updated automatically! - Restart the application

    }

}

 

Yes, we all believe that this can be achieved very easily using the above code! But No. According the Microsoft

 

documentation (I read it in blog, I didn't read the complete SL 5 documentation), A Silvelright OOB application will

 

be automatically updated in the following conditions

 

1. It should not run with elevated trust


2. If it runs with elevated trust, the XAP file should be signed!

 

-- Now I need to sign the application, to make the above code to update the application work!

I tried creating a certificate using makecert.exe and signed the XAP file using signtool.exe with the certificate I

 

created in my local system. My attempt FAILED when published in the server! - I don't know the reason, but again, I

 

learned from one of the blog that I should get a certificate from any of the providers like verisign, StartSSL etc.

I managed to get one and signed the XAP manually using the following code

 

signtool sign /v /f "C:\MyApplicationFolder\Certificates\MyCodeSignCert.pfx" /p myPassword "C:\MyApplicationFolder\ApplicationName.Silverlight\ClientBin\ApplicationName.xap"

 

So, as per the Microsoft documention, my application should get updated automatically! But still the application is

 

not getting updated!

 

Issue 2    : I changed the OnCheckAndDownloadUpdateCompleted method implementation as follows to capture the error

 

private void OnCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)

{

    if (e.Error == null && e.UpdateAvailable)

          {

        // Application updated successfully

    }

    else if (e.Error != null)

          {

        // Error occured while updating / getting update

          }

}

 

Error     : "The operation are not supported on this plattform"

Cause    : This is a known bug. Check this

 

Solution: Remove the "InBrowserSettings.xml" in the properties folder of the project.

Close the project in visual studio, open the project file with notepad and remove the following entries from the

 

file

<InBrowserSettingsFile>Properties\InBrowserSettings.xml</InBrowserSettingsFile>  

<RequireInBrowserElevation>true</RequireInBrowserElevation>

Once you remove and save the project file, Open the project again with visual studio, rebuild your project, sign it

 

and publish the new XAP. SOLVED! But now,

 

Issue 3    : Application is getting updated every time I open it from the client!

Cause    : HttpHeaders in the IIS is set expire cache immediately

Solution: Change the setting to expire cache after 1 day (or n days)

If you are facing similar issues with your Silverlight out of browser application, just try this!

 

 

 

Comments