Showing posts with label Silverlight. Show all posts
Showing posts with label Silverlight. Show all posts

Tuesday, March 13, 2012

Signing a LightSwitch application with test certificate for development purposes

When you deploy a LS app in house on the intranet to run on the client desktop and you do not have a certificate, then the next time you upgrade your application, the clients will not update automatically, but require the user to uninstall the app, then browse to the url for the published app and install it again.
This is the message you would get when launching the app from the desktop icon:
An error occurred while checking for updates. make sure you are running the latest version of the application by uninstalling it from Add/Remove programs in the Control Panel, and then re-installing the application.
Details: Cannot update application, the installed application and update candidate differ in certificate/signature state.
Conclusion: LS desktop apps need a certificate to automatically update after deployment of a new version. Alternatively we can deploy the app to run in the browser.
John Papa's blog explains how to manually create a certificate

Create root certificate

Run VS2010 command prompt
makecert -n "CN=JDH Root Certificate Authority" -r -a sha1 -sv c:\Development\Certificate\TestOOBRootCA.pvk c:\Development\Certificate\TestOOBRootCA.cer -sr LocalMachine -sky signature
clip_image002
Enter password (2x)
Click OK
clip_image004
Re-enter password
OK

“Succeeded“

Create child certificate from root certificate

Run VS2010 command prompt
makecert -sv c:\Development\Certificate\TestOOBCodeSigningCA.pvk -iv c:\Development\Certificate\TestOOBRootCA.pvk -n "CN=JDH Test OOB child Code Signing CA" -ic c:\Development\Certificate\TestOOBRootCA.cer c:\Development\Certificate\TestOOBCodeSigningCA.cer
clip_image002[1]
Use the same password

clip_image006

Use the same password
Issuer password
Use the same password

“Succeeded“

Generate PFX file

This file contains pwd and private key in one file for convenience.
pvk2pfx -pvk c:\Development\Certificate\TestOOBCodeSigningCA.pvk -spc c:\Development\Certificate\TestOOBCodeSigningCA.cer -pfx c:\Development\Certificate\TestOOBCodeSigningCA.pfx -po password
Warning: the word password in the command line above, should be replaced by another password, you will need this password when you use this certificate in the LightSwitch Publish Application wizard.
image
enter the password used for creating the root and child certificate.
“Succeeded“
These are the files up to now
clip_image002[6]
The 5 last files are the ones from my example that count, (I have already added a 2nd child cert Test2... )

Use the certificate in LS deployment

In Visual Studio 2010, publish the LS application, menu Build – Publish…
LightSwitch Publish Application wizard starts.
image
image
image
Service Url: http://<myserver>
User Name: a windows user account that has admin rights on the webserver, this account will be used by the deployment agent to do the web installation on the server.
Allow untrusted certificate: you cannot check this box, once you have entered url and name. (to be investigated later what purpose this server).
Other connections
image
Click ‘Browse for a certificate…’
Browse to the folder with the PFX certificate and select the file c:\Development\Certificate\TestOOBCodeSigningCA.pfx
image
enter the password from the Generate PFX file command (not from the root or child certificate)
image
Remark: the expiration date is 2040, and not 2013 as it would have been, if the test certificate was created by the wizard ‘Create a test certificate..’
Remark: next time you deploy a LS application this certificate will be available in this computer’s store. So next time you can click ‘Select a certificate in this computer’s store’.
Finally, In the Publish summary of the wizard, click on publish.
Visual Studio Output window finishes with: ========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
Now browse to the server on which the app was deployed. http://<Myserver>/<MyApp>
The installation page appears with an installation button, click on the button ‘Install MyApp’
image
Click on Install
The application gets installed, a shortcut is added to the desktop and at the end of the installation the app starts.
So far so good. Now what will happen when an update to application is deployed?

Deploy an update of the application

IN VS201 added a new screen, build and deploy with same parameters. Successfully published.
When clicking on the desktop icon on the client to start the app, the application pops up
image
close this window and start the app again. The new screen is available in the LS app menu.

Tuesday, June 22, 2010

2010_06_13 Sea-kayak at L'Anse St-Jean (Saguenay fjord)

A 3 hour trip by sea-kayak in the Saguenay fjord, starting at L'Anse Saint-Jean.

2010_06_18 quebec city

A splendid bike trip alongside the St-Laurens river. In the background you can see Québec City.

Wednesday, June 09, 2010

Mauricie dag 5





Lang geslapen. Voor het ontbijt mochten we zelf de eitjes bij de kippen gaan roven. Naar het dorp Saint-Jean-des-Piles vlakbij het park om onze kayak te reserververen. We krijgen de roeispanen en reddingsvesten mee, aan het meer bij het park moeten we dan gewoon een kayak nemen en wegroeien. Een tocht met de wagen van 3 kwartier tot aan Lake Wapizigonke, wagen geparkeerd en met roeispanen tot aan strand bij meer waar de kayaks liggen. Met de kayak een uur gevaren op 2 stukken van het meer die via het moeras en een beverdam aan elkaar verbonden waren. Na een uur beland bij het voetpad dat naar Waber waterval leidt. Nog 2 uur gewandeld en dan terug een uur met de kayak. Met de wagen terug naar B&B, nog wat eten en praten met de andere gasten.

Mauricie dag 4




Laatste ontbijt in Montreal. Met de express bus naar Montreal airport om huurwagen op te halen. Met de wagen via de highway naar le Parc National de la Mauricie. 's middags aankomst aan l'auberge de saint Maurice. Een wandeling van 7 km in het park. OM 19:00 met de gids naar beren gaan kijken, in een observatiehut, na een uur een grote zwarte beer gezien. Gaan eten en slapen.

Monday, June 07, 2010

Montreal dag 3


Regen van 's morgens tot 's avonds. Bagel geproefd in bakkerij. Dome bezocht. Museum van moderne kunst. Shopping, alles binnendeurs.'s avonds liitle Italy om een spaghetti te eten. Geen fietstocht want te nat en te fris.

Sunday, June 06, 2010

Montreal dag 2






Lekker ontbij met wafels, vers fruit en esdoorn siroop geserveerd door Philippe de gastheer. Kennis gemaakt met een amerikaans koppel dat ook verblijft in het B&B. Met de metro naar oud montreal - wandelen door de stad - kathedraal - stadhuis waar ze een nieuwe spits op de toren plaatsten - de haven met het cirque de soleil - aan de pier de klokketoren beklommen - er was ook een herdenking voor de gesneuvelden met saluutschoten en last post - wandelen door de ondergronds stad - shopping - iets gekocht in een supermarkt om te eten 's middags. namiddag nog wandelen - china town - in de avond eten in een vegetarisch thai restaurant zeer lekker. - vroeg gaan slapen.

Saturday, June 05, 2010

Montreal dag 1




Vlucht met air transat - aankomst Pierre Trudeau Airport 10:50 - declaratie douane 3 appels
Express bus van airport naar Bus station bij Universiteit - 3 blokken verder gaan met valies naar ons B&B Le Saint-andré des arts
Goed onthaal door Philippe onze gastheer - espresso machine in de keuken - verfrist - met metro naar Montreal Olympic park en botanical gardens - gewandeld door het park - zeer groot - veel eekhoorns
Terug met metro naar B&B - verfrist - Metro naar bistro 'Station F' zeer lekker eten.
Slapen.

Friday, May 14, 2010

silverlight 4 training kit and Silverlight 4 MVVM video

The Silverlight 4 Training Course includes a whitepaper explaining all of the new Silverlight 4 features, several hands-on-labs that explain the features, and a 8 unit course for building business applications with Silverlight 4.
It can be downloaded from here

Via RSS feed in VS2010 I found this training video for Silverlight 4 MVVM

Wednesday, February 17, 2010

Silverlight DataForm with Combobox

Using Silverlight 3, WCF RIA services Beta and Visual Studio 2008. Since comboboxes do not work out of the box when used inside Dataforms, I tried using convertors. This is workable but it requires a lot of coding. This blog has an interesting approach: http://justgeeks.blogspot.com/.

Monday, February 15, 2010

Using the Silverlight Treemap and WCF RIA services to display business data


Introduction

A client of mine wanted to visualize his customers by city they live in. His customer addresses reside in the SQL server database I've set up for him.

Since I have started development of a small sales force Silverlight app for him, I looked at what could be done with Silverlight to visualize his data. There are several possibilities, such as visualization on a Bing map, but to start off and keep it simple and to avoid spending too much time on this, I decided to use the Treemap control.

Background

The data is stored in an Address table in a database in SQL Server 2008. All the Addresses are located in Belgium and have all been given a City name and zip code.

The Silverlight project is written in Visual Studio 2008 with Silverlight 3 and WCF RIA services beta.

References

Treemap in Silverlight 3 article by Diptimaya Patra in c-sharpcorner.
Using stored procedures in the Entity Framework by Julie Lerman in thedatafarm.
Articles about WCF RIA services by Brad Abrams, Tim Heuer and many others.

The result

The screenshot at the top of this article shows the result: a Treemap control that visualizes the addresses per city. The cursor was hovering over the city of Bruges (Brugge) with 70 customers.


The solution


The Data tier: SQL Server


The SQL server database needs a view or stored procedure that groups the addresses by city and zipcode. Larger cities have different zipcodes for one city name, so the city and zipcode need to be concatenated. Since my middle-tier is going to be WCF RIA services and the Entity Framework, I need a result that has a primary key too. And because of a blatant problem with the Entity Framework designer that does not allow you to specify a primary key field on a view, I'll have to fake my primary key.


Stored procedure


Use a stored procedure to make it fit in my Entity Framework. The stored procedure uses ROW_NUMBER() as a column with name ID and this will be my primary key column.

The procedures returns a recordset with 4 columns: ID, Gemeente, Tooltip, Aantal.



CREATE Procedure dbo.upAddressTreemap
AS
BEGIN
SET NOCOUNT OFF;
SELECT CONVERT(int,ROW_NUMBER() OVER (ORDER BY Gemeente, Zipcode)) AS 'ID'
,RTRIM(City + ' ' + Zipcode) AS Gemeente
, City + '-' + Zipcode + ' Aantal:' + Convert(varchar,COUNT(*)) AS Tooltip
, COUNT(*) AS Aantal
FROM dbo.Contact
GROUP BY City, Zipcode
END

The first 3 records of the recordset can be seen here:

ID

Gemeente

Tooltip

Aantal

1

Aalbeke 8511

Aalbeke-8511 Aantal:7

7

2

Aalst 9300

Aalst-9300 Aantal:5

5

3

Aalter 9880

Aalter-9880 Aantal:18

18

Dummy table

Because I do not like to edit xml in the entity framework edmx file, I create a dummy table that will only be read by the Entity Framework designer.

The table contains the same fields as the resulting recordset of my stored procedure. This table will be used by the framework designer, later I will add the stored procedure in the Entity framework and map it to this table.

CREATE
TABLE [dummy].[AddressTreemap](

[ID] [int] NOT
NULL,

[Gemeente] [varchar](100)
NOT
NULL,

[Tooltip] [varchar](100)
NOT
NULL,

Aantal [int] NULL,


CONSTRAINT [PK_ AddressTreemap] PRIMARY
KEY
CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX
=
OFF,
STATISTICS_NORECOMPUTE
=
OFF,
IGNORE_DUP_KEY
=
OFF,
ALLOW_ROW_LOCKS
=
ON,
ALLOW_PAGE_LOCKS
=
ON)
ON [PRIMARY]

)
ON [PRIMARY]

The middle tier: EF and WCF RIA services

The standard procedure to make a Silverlight database application is to create an entity framework edmx file in the Web project and to add a Domain Service class based on this entity framework.

The Entity Framework designer has problems using views when it cannot find a primary key. My solution is to create a dummy table with the necessary fields and the primary key. Then to add a stored procedure to the EF and to map this procedure to the dummy table.

The solution to this is based on the article by Julie Lerman.

Entity Framework

In Visual Studio 2008 in my Silverlight.Web project I had already added an ADO.NET Entity Data Model.

Step 1

Create the Entity with the designer wizard to add the dummy table and the stored procedure.

The dummy table is shown as an entity on the design surface.

The stored procedure can be found in the model browser in the Stored procedures section of the model store.

Save and build this model.

Step 2

Add an import function in the model browser, by rightclicking on the stored procedure name in the model browser. The return type is the AddressTreemap Entity.

The result in the model browser

Skip Step 3 and 4.

Step 5

To be checked.

Domain Service Class

Save and build the project.

Add a domain service class to the project. I work with partial classes so I can recreate the Domain service class whenever my entity framework changes.

I make the generated AdressenService class partial and then add a new class with the filename AdressenService.partial.cs. I use new this partial class to add all my custom methods. Whenever the Entity model changes, I can regenerate my DomainService class without losing my custom code. This tip I found in an blog post by someone else, but I cannot remember the link any longer.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

namespace Adressen.Web

{


public
partial
class
AdressenService

{


public
IQueryable<AddressTreemap> GetAddressTreemapSproc()

{


AddressTreemap entities = new
AddressTreemap ();

System.Data.Objects.ObjectResult< AddressTreemap > dbResults =


this.ObjectContext.upAddressTreemap();


return (IQueryable< AddressTreemap >)dbResults.AsQueryable();

}

}

}

Save and build the project. This finalizes our middle-tier section.

Presentation tier

To finish off, the result will be displayed in a Silverlight Page with a Treemap control and with the RIA services DomainDataSource control. Everything will be handled in xaml, no code behind will be needed.

DomainDataSource

In the UserControl attributes section add a reference to the Silverlight.web application


xmlns:App="clr-namespace:AdressenTreemap.Web"

In the Grid section add a Grid resources collection that refers to the App namespace


<Grid.Resources>


<App:AdressenContext
x:Key="adressenContext"/>


</Grid.Resources>

Drag a DomainDataSource control from the toolbox in the Grid section. This will automatically add the namespaces.


xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"

The DomainDataSource has the following properties: Autoload True, QueryName refers to the method we made in the partial class.


<riaControls:DomainDataSource x:Name="ddsTreemap" AutoLoad="True"


QueryName="GetAddressTreemapSprocQuery"


DomainContext="{Binding Source={StaticResource
adressenContext
}}">


</riaControls:DomainDataSource>

Sorting has been added out of the experience I've had with datagrids: If I do not specifiy sorting , then most often you get errors.

For sorting, add the following namespace


xmlns:datagroup="clr-namespace:System.Windows.Data;assembly=System.Windows.Controls.Ria"

Sorting is done on the ID column of the datasaource.

<riaControls:DomainDataSource … <riaControls:DomainDataSource.SortDescriptors>


<datagroup:SortDescriptor PropertyPath="ID"/>

</riaControls:DomainDataSource.SortDescriptors>

</riaControls:DomainDataSource>

Treemap

Drag a treemap control onto the grid, below the DomainDataSource. This automatically adds a reference to the following namespace:


xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"

The treemap has to use the data from the DomainDataSource. A Data range from Blue (most) to Magenta (least) is specified.


<visualizationToolkit:TreeMap x:Name="trm" ItemsSource="{Binding Data, ElementName=ddsTreemap}"
>



<visualizationToolkit:TreeMap.Interpolators>


<visualizationToolkit:SolidColorBrushInterpolator TargetName="itemBorder" TargetProperty="Background"


DataRangeBinding="{Binding
Aantal
}" From="Blue" To="Magenta" />


</visualizationToolkit:TreeMap.Interpolators>


<visualizationToolkit:TreeMap.ItemDefinition>


<visualizationToolkit:TreeMapItemDefinition ValuePath="Aantal">


<DataTemplate>


<Border x:Name="itemBorder" BorderBrush="Black" BorderThickness="1" ToolTipService.ToolTip="{Binding
Tooltip
}">


<TextBlock x:Name="trmGemeente" Foreground="White"


Text="{Binding
Gemeente
}" VerticalAlignment="Center"


TextAlignment="Center" TextWrapping="Wrap"/>


</Border>


</DataTemplate>


</visualizationToolkit:TreeMapItemDefinition>


</visualizationToolkit:TreeMap.ItemDefinition>


</visualizationToolkit:TreeMap>


</controlsToolkit:DockPanel>

Layout and user experience

To round up, I added grid columns and rows to center my treemap in the page.

To show the user the data is loading I've added a BusyIndicator.

To explain what is being displayed, a Dockpanel was used in which a textbox was added with an axplanatory title together with the t

Below is the final xaml code (example was made in a masterpage).

<UserControl


xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"


xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"


xmlns:datagroup="clr-namespace:System.Windows.Data;assembly=System.Windows.Controls.Ria"


xmlns:App="clr-namespace:AddressTreemap.Web"


xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"


xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"


x:Class="AddressTreemap.MainPage"


xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"


xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"


xmlns:d="http://schemas.microsoft.com/expression/blend/2008"


xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"


mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">


<controlsToolkit:BusyIndicator x:Name="busyIndicator"


IsBusy="{Binding IsBusy, ElementName=ddsTreemap}"


BusyContent="Bezig met laden" Grid.RowSpan="3" Grid.ColumnSpan="3">


<Grid x:Name="LayoutRoot" Margin="-8,8,8,-8">


<Grid.Resources>


<App:AdressenContext
x:Key="adressenContext"/>


</Grid.Resources>


<Grid.ColumnDefinitions>


<ColumnDefinition Width="0.1*"/>


<ColumnDefinition Width="0.8*"/>


<ColumnDefinition Width="0.1*"/>


</Grid.ColumnDefinitions>


<Grid.RowDefinitions>


<RowDefinition Height="0.1*"/>


<RowDefinition Height="0.8*"/>


<RowDefinition Height="0.1*"/>


</Grid.RowDefinitions>


<controlsToolkit:DockPanel LastChildFill="True"

VerticalAlignment="Top" Grid.Column="1" Grid.Row="1" d:LayoutOverrides="Width" Height="384">


<riaControls:DomainDataSource x:Name="ddsTreemap" AutoLoad="True"


QueryName="GetAddressTreemapSprocQuery"


DomainContext="{Binding Source={StaticResource adressenContext}}">


<riaControls:DomainDataSource.SortDescriptors>


<datagroup:SortDescriptor PropertyPath="ID"/>


</riaControls:DomainDataSource.SortDescriptors>


</riaControls:DomainDataSource>


<Grid x:Name="gridTitel" Background="DarkGray"
controlsToolkit:DockPanel.Dock="Top">


<TextBlock x:Name="txtTitel" Text="Verdeling per gemeente van adressen voor mailing met de post"


TextAlignment="Center" TextWrapping="Wrap" Height="32" FontSize="18"


Foreground="White"


Margin="2"/>


</Grid>


<visualizationToolkit:TreeMap x:Name="trm" ItemsSource="{Binding Data, ElementName=ddsTreemap}"
>



<visualizationToolkit:TreeMap.Interpolators>


<visualizationToolkit:SolidColorBrushInterpolator TargetName="itemBorder" TargetProperty="Background"


DataRangeBinding="{Binding Aantal}" From="Blue" To="Magenta" />


</visualizationToolkit:TreeMap.Interpolators>


<visualizationToolkit:TreeMap.ItemDefinition>


<visualizationToolkit:TreeMapItemDefinition ValuePath="Aantal">


<DataTemplate>


<Border x:Name="itemBorder" BorderBrush="Black" BorderThickness="1" ToolTipService.ToolTip="{Binding Tooltip}">


<TextBlock x:Name="trmGemeente" Foreground="White"


Text="{Binding Gemeente}" VerticalAlignment="Center"


TextAlignment="Center" TextWrapping="Wrap"/>


</Border>


</DataTemplate>


</visualizationToolkit:TreeMapItemDefinition>


</visualizationToolkit:TreeMap.ItemDefinition>


</visualizationToolkit:TreeMap>


</controlsToolkit:DockPanel>


</Grid>



</
controlsToolkit:BusyIndicator>

</UserControl>

Conclusion

With some creative computing on the database side, I was able to give my client a new visual presentation of his business data with minimal development time.


Monday, February 08, 2010

Hyperlink button style as command button

This link explains how to make a hyperlink button look like a windows command button:
hyperlinkbutton

Debug WCF RIA services with Fiddler

When WCF Services used by Silverlight 3 app give an error message like 'Load operation failed for query...' then you can trace the servide call with Fiddler. You will notice the address of the RIA services.

The service address is http:////ClientBin/-Web-Services-.svc

Silverlight 3 and WCF RIA services 'not found' error

set the references to copy local for the following dll's

System.Componentmodel.DataAnnotations.dll
System.Web.DomainServices.dll
System.Web.DomainServices.EntityFramework.dll
System.Web.Ria.dll

For my latest application I had followed the directives as I found them on some websites and only copied the last 3 dll's to the bin folder. Which made sense because you get errors on the silverlight pages. But when I tested the application I got 'not found' errors when trying to read data. The System.Componentmodel.DataAnnotations.dll needs to be there as well for the RIA services to work.

Thursday, January 28, 2010

Silverlight application themes for Silverlight 4

I have used the silverlight application themes from Tim Heuer in the Visual Studio 2010 beta with Silverlight 4 and they work.

  • Put the Style.xaml that you downloaded from one of the themes in the Assets folder of your Silverlight project.
  • Overwrite the existing one.
  • In VS 2010 select the Style.xaml and change the property Copy to output directory into 'Copy always'.

 

Silverlight 4 WCF RIA Services Line of Business Application Hands-On Lab

In this 108 page hands-on lab you will learn how to use Beta 2 of Visual Studio 2010 and Beta 1 of Microsoft Silverlight 4 to create a data driven line of business style rich internet application that implements many of the new features that Silverlight 4 introduces. 

These features are implemented in the lab:

  • True multi-tier architecture.
  • Entity framework and service layer definition.
  • Data filtering, paging, sorting and grouping.
  • Data modification and validation.
  • Foreign key management.
  • Projections.
  • Programmatic printing from a Silverlight application.
  • COM interop with Microsoft Excel and running full-trust out-of-browser.

Great work from Sascha Corti and Ronnie Saurenmann!

Monday, January 04, 2010

Silverlight 3 How to display the version number of my silverlight assembly

On the About page of my silverlight 3 app I wanted to display the version number of the silverlight assembly (not of the web application).

In the Silverlight forums I found a simple solution by PBROMBERG:
Assuming that the xaml page contains a textblock txtVersion with no text.

Assembly asm = Assembly.GetExecutingAssembly();
string[] parts = asm.FullName.Split(',');
txtVersion.Text = parts[1];

the resulting version info will be displayed like:
Version=1.0.2.0