Saturday, January 23, 2010

New features in Silverlight 4 Beta: C# 4 & Sharing Assemblies with .NET Apps

Have you tried to use new C# 4 features in Silverlight 4 Beta ? Read this post.

I’ve made Silverlight sample (CSharp4) to demonstrate new C# 4 features and new BCL types

  1. Dynamic Binding
  2. Named and Optional Arguments 
  3. Tuples

Silverlight 4 has also changes in Collection Sets and parsing and formatting time intervals.

Covariance and contravariance don’t work in Silverlight 4 Beta (I have tested it – you can’t compile code with variance).

I’ve built second Silverlight example (ModifyHTMLbyNET) to show HTML /JavaScript integration with  dynamic type.

Both samples you can download below.

Dynamic type is very useful for native integration (COM), too.

You can read about sharing Silverlight assemblies with .NET here and here.

Useful links

Tuesday, January 19, 2010

New features in Silverlight 4 Beta: WCF Data Services

ADO.NET Data Services has changed its name to WCF Data Services. Today I’ll write about consuming these data services from Silverlight 4 Beta client.

I have created Silverlight 4 application consuming .NET 4.0 WCF Data Service in x-domain scenario (which is supported in updated data services). Silverlight 4 client library includes most of the new features previewed in the ADO.NET Data Services CTP2.  Using the Visual Studio 2010 Beta 2 Add Service Reference feature with the Silverlight 4.0 Beta requires a few extra steps from the normal process.


The Open Data Protocol Visualizer for Visual Studio CTP1  (see screenshot above)  provides a read-only visualization of the types, properties, associations, and other objects in the Entity Data Model (EDM) returned from an Open Data Protocol’s metadata endpoint. You can download and install it using Extension Manager.

Useful links

Saturday, January 16, 2010

New features in Silverlight 4 Beta: Multicast, Authentication, WCF

This post will be about some new communication features in Silverlight 4.  In the coming days I’ll write about frameworks built on top of WCF:  WCF Data Services (formerly ADO.NET Data Services) and WCF RIA Services (formerly .NET RIA Services).

What’s new?

I have tested multicast, client http stack authentication and WCF NetTcpBinding (from client to server and duplex). You can download sources below.

I had some problems to get IIS configured to use Net.TCP.  Mike had written an excellent post about using WCF NetTcpBinding with Silverlight 4. You should read it.

Useful links

Tuesday, January 5, 2010

New features in Silverlight 4 Beta: Managed Extensibility Framework (MEF)

The Managed Extensibility Framework (MEF) is a new library in Silverlight 4. MEF enables you to build modularized applications whose components can be added in an incrementally. MEF ships as part of Silverlight 4, but we’ve also made a Silverlight 3 compatible version of MEF available on codeplex at (current version: Preview 8). Read this post!

I have create my sample application (VS solution: MEF). There’ are  excellent showcasts prepared by Mike Taulty. They show many MEF features. I have make VS solution (MEF2) with almost all presented cases.

MEF  features in these 2 solutions:

  • Exports ([Export])
    • Composable Part, properties, methods (as delegates)
    • Export metadata ([ExportMetadata(key, value)])
    • Custom Export Attributes ([Custom]: [Export])
    • Inheritance ([InheritedExport])
    • Life time (option: [PartCreationPolicy]:  Any, Shared, Nonshared)
  • Imports ([Import])
    • Properties, constructor parameters ([ImportingConstructor]), fields, collections ([ImportMany]),  methods (as delegates)
    • Parameter imports (Implied import  - type of parameter (by default),  Explicit import - contract)
    • Importing Metadata
    • Requirement ([Import] option:  AllowDefault)
    • Recomposition (option: AllowRecomposition)
    • Notifications (IPartImportsSatisfactionNotification)
    • Rejection (Stable Composition)
    • Lazy imports (Lazy<T>)
    • Dynamic Instantiation (PartCreator<T>)
  • Composition & hosting
    • Part Initializer (PartInitializer.SatisfyImports)
    • Catalogs (AssemblyCatalog, .NET: DirectoryCatalog / Silverlight: PackageCatalog, TypeCatalog, AggregateCatalog)
    • Containers (CompositionContainer, CompositionHost.InitializeContainer)
    • Export Providers (CatalogExportProvider, AggregateExportProvider)
  • Silverlight 4 Beta Toolkit: Dynamic XAP downloading (PackageCatalog, Package.DownloadPackageAsync)


On the Internet there are many interesting samples with MEF and Silverlight 3 or 4 Beta. For example:

HauseSpacePlanner (PDC 09)

MEF_03 MEF_04

ExtensibleGrid (Sample in MEF sources, PDC 09)

MEF_05A MEF_05MEF_06

Silverlight 3 Navigation with MEF (Brad Abrams)

MEF_07 MEF_08

Useful links