Silverlight Navigation Project (VS2008) – Question



I have created a minimal project to illustrate the problem. I am using VS2008 SP1 and Silverlight 3.

I created a Silverlight Navigation Project, Added a Product Model, A SingleProductView, and a ProductViewModel.

I added 2 new Pages Review.xaml and Cart.xaml.

Review.xaml uses the SingleProductView to display the product details and an [add to cart] button which when clicked should add the product to the Shopping Cart and then navigate to the Cart.xaml page.

The problem I have is in the SingleViewModel.

The SingleViewModel contains a button (btnAddToCart), which should add the product details to the cart (will be a database populated using a web service call) and then it should navigate to the Cart Page (Cart.xaml)

<UserControl x:Class="SL3NavTest01.SingleProductView"
    d:DesignWidth="950" d:DesignHeight="800">
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
            <Image   Source="/SL3NavTest01;Component/Assets/Images/VS2010Ultimate.jpg" Stretch="None" Height="200" Width="200"
											HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <StackPanel Margin="20,0,0,0">
                <TextBlock Text="{Binding Name, Mode=TwoWay}" TextWrapping="Wrap" Margin="0,30,40,0"
									FontFamily="Verdana" FontSize="18" Foreground="Black" FontWeight="Bold" />
                <StackPanel Orientation="Horizontal" Margin="0,30,0,0">
                    <TextBlock Text="Price: " FontFamily="Verdana" FontSize="16"
										Foreground="Black" FontWeight="Normal" />
                    <TextBlock Text="{Binding Price, Mode=TwoWay}"
										FontFamily="Verdana" FontSize="16" Foreground="Black" FontWeight="Normal" />
                    <Button x:Name="btnAddToCart" Width="75" Margin="0,30,0,0" Content="Add To Cart"

Imports System.Windows.Browser
Partial Public Class SingleProductView
    Inherits UserControl

    Public Sub New()
    End Sub

    Private Sub btnAddToCart_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        '   The project has been simplified so as to only include the structure and context of where the
        '   problem exists.
        '   On clicking this button the code should:
        '   1.  Add Product to Shopping Cart (via Web Service)
        '   2.  Then navigate to the Shopping Cart Page (\views\Cart.xaml)
        '   Code to add product to shopping cart (I can do this part!)
        '   ----------------------------------------------------------
        '   Code to navigate to Cart.xaml (This is the problem!!!)
        '   ------------------------------------------------------
        '   I can't find a syntax that would do the equivalent of the following:
        '   ContentFrame.Navigate(New Uri("/Cart", UriKind.Relative))
        '   This is my solution:
        '   I know the view is used on the "Review" page and I want to navigate to the "Cart" page.
        '   Also required Imports System.Windows.Browser
        Dim strNav As String = HtmlPage.Document.DocumentUri.ToString
        strNav = Replace(strNav, "Review", "Cart")
        HtmlPage.Window.Navigate(New Uri(strNav, UriKind.Absolute))
        '   It may be that I should use a Hyperlink button, but I am uncertain as to how I would be able
        '   to Add the Product to the Shopping Cart first then Navigate to the Cart.xaml Page.
        '   I realize that this is not stricly MVVM, but I am looking to get the simple solution working
        '   first.
        '   Feel free to provide references to the "correct/best practice" way to do this.
    End Sub
End Class

Found this thread
which has been read 99,870+ times (may suggest the tiniest of gaps in silverlight functionality or documentation).

My solution is as follows:

        Dim strNav As String = HtmlPage.Document.DocumentUri.ToString
        strNav = Replace(strNav, “Review”, “Cart”)
        HtmlPage.Window.Navigate(New Uri(strNav, UriKind.Absolute))


Imports System.Windows.Browser

I have attached the original simplified project solution zip file so that you can try out various solutions

Download and rename to and see what you can come up with.

SL3NavTest01TestPage.html should be used as the start page.

The Luddite Developer.


Silverlight Security – Code Obfuscation – Part Two

Seems like many .NET developers nowadays are concerned with deploying their apps without applying any form of protection on them beforehand.
As mentioned in a previous post silverlight code must be downloaded to the client machine, this makes it possible to recover the original source code using tools such as ILDasm & .NET Reflector.

Most of us, when we think of obfuscating silverlight apps, refer to a form of obfuscation called ‘symbol renaming’ which means changing the names of classes, methods & variables to meaningless names. The result is a much harder code to read, that makes it more difficult for someone to follow the semantic meaning of the internal structures included in the obfuscated assembly.

This doesn’t come without a price, often due to usage of reflection API either directly by the programmer who wrote the assembly or indirectly by the .NET class library relying on reflection API (e.g. xml serialization, web services) the code would break.
In addition symbol renaming makes it more difficult to understand exception stack trace information collected from production environments as original method names are no longer available. The image below demonstrates how an exception stack trace may look like:

Obfuscated call stack

Developers searching for non-invasive solutions, one that doesn’t suffer from the flaws mentioned above may be interested to look at CliSecure .NET Obfuscator, this is a code protection solution that offers new forms of obfuscation that are effective, easy to configure and integrate with your existing silverlight apps or others still under development  (support for windows phone 7 included).

CliSecure .NET Obfuscator site

On top of symbol renaming CliSecure .NET obfuscator introduces advanced forms of control flow obfuscation and a new obfuscation technique called ‘method call obfuscation’.

Control flow obfuscation aims to destroy existing code patterns and transforms them to different ones that are much harder to follow, the image below shows how a simple for loop would look like after using this method.

Control flow obfuscation demonstrated

Even more interesting is to see the IL representation of the method as shown in .NET reflector, it appears that .NET reflector fails translating the byte code to C# or any other .NET language:

Method call obfuscation hides calls to external library calls, either ones that reference the .NET class library or ones that reference other assemblies developed internally. External calls normally survive symbol renaming as method binding occurs during run time using the method name, however using this method binding is attempted using the method token, an internal token stored within the metadata section that can be used to resolve methods calls.

Method call obfuscation code snippet

As seen in the image below the call to Console.WriteLine is replaced with a call to a delegate method that hides the original call. This method effectively breaks the application code flow, making it harder to browse through the code flow using standard reflection tools.

Which versions of Silverlight 3 components do I need for VS2008 SP1 and VS2010?

Which Versions of Silverlight 3 Components are required for VS2010

Which Versions of Silverlight 3 Components are required for VS2010

Running on a XP SP3 system.

I want to keep developing applications using VS2008 SP1, Expression Studio 3 and Silverlight 3.  I don’t want to break anything.

I would like to download and start using VS2010 again without breaking anything.

I noticed the following installation issue regarding VS2010 and Silverlight 3 SDK.

Visual Web Developer in Visual Studio 2010 has support in box for Silverlight 3 development and includes the Silverlight 3 developer runtime and Silverlight 3 SDK build 3.0.40818.

Silverlight 3 Tools for Visual Studio 2008 and Expression Blend 3 included SDK build 3.0.40624.

Silverlight 3 SDK build 3.0.40818 cannot be installed on machine where build 3.0.40624 is already installed. If you install Visual Studio 2010 on a machine that already has build 3.0.40624 installed, Visual Studio 2010 will indicate that the Silverlight 3 SDK failed to install, however you will still be able to do Silverlight development on Visual Studio 2010 with build 3.0.40624.

Silverlight 3 SDK build 3.0.40818 contains the following updates:

  • Remove dependency on .NET 3.5 and allow build when only .NET 4 is installed
  • Support for use of non-unicode characters in xap name
  • Improvements to refactoring and intellisense

To get build 3.0.40818of the Silverlight 3 SDK, uninstall Silverlight 3 SDK build 3.0.40624 from Add/Remove Programs and then install Silverlight 3 SDK build 3.0.40818 from:


I checked my own system using the Add/Remove Programs utility and found the following:

Currently Installed Program Version
Microsoft Silverlight 3.0.50106.0
Microsoft Silverlight 2 SDK 2.0.31005.0
Microsoft Silverlight 3 SDK 3.0.40624.0
Microsoft Silverlight 3 Toolkit – July 2009 3.0.30702.0037
Microsoft Silverlight 3 Tools for Visual Studio 2008 SP1 –ENU 9.0.30730.126

I found that I can get the following Downloads:

Download URL
Microsoft Silverlight 3 Toolkit – Nov 2009
Microsoft Silverlight 3 SDK version 3.0.40818
Microsoft Silverlight 3 Tools for Visual Studio 2008 SP1 –ENU



  1. I do not develop for Silverlight 2, can this be safely uninstalled?
  2. In what order do I need to remove installed programs/versions and in what order do I need to install new versions?
  3. If I uninstall the Silverlight 3 Toolkit – July 2009, will this break existing applications using this toolkit?
  4. Can the Silverlight 3 Toolkit – July 2009 and Silverlight 3 Toolkit – Nov 2009 be safely installed side by side?
  5. Is there a general rule for what can and cannot be installed side by side with the various Silverlight components?
  6. I already have the current version for Microsoft Silverlight 3 Tools for Visual Studio 2008 SP1 –ENU installed.  Will it need to be re-installed?

Thanks in advance for any replies.