Unity 2.0 for Silverlight 4

Dec 8, 2010 at 5:47 PM

I am just getting started with PRISM v4 and using Unity 2.0 rather than MEF so need to get up to speed with Unity 2.0 as quickly as possible. This is proving extremely frustrating, partly because the PRISM documentation just assumes you're already familiar with Unity, and partly because it seems completely unaware of Silverlight-specific features like Application Extension Services and how DI should be used with these in conjunction with the supplied UnityBootstrapper mechanism.

My first stop for trying to better understand Unity 2.0 was the Unity 2.0 for Silverlight QuickStart.  Despite being issued in April 2010 the documentation assumes you are building the QuickStart with Visual Studio 2005 or Visual Studio 2008 (for which you are told the code needs to be converted). If I try to open the solution in Visual Studio 2010 the upgrade fails and I have two "(unavailable)" projects. The error reads "Unable to read the project file StopLight.csproj" and appears to be down to an assumption that the user has Silverlight 3 installed (there is an imported project reference to C:\Program Files\MSBuild\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets).

I found some Hands-on-Labs but these were not geared towards Silverlight and when even the first beginning solution (before Unity is even introduced) fails with a service 404 error I decided this looked like more "not applicable to .NET 4 or obsolete" shenanigans.

So it seemed like the only way to get to grips with this stuff if you're a Silverlight 4/Visual Studio 2010 developer is to wade through the reference documentation.  Unfortunately this is only available in .chm format - no pdf has been made available as was the case for PRISM. 

Does anybody have any good links for getting started with Unity for Silverlight 4/Visual Studio 2010. It's tough enough telling developers they have to wade through the weighty Prism documentation without having to add the weighty Unity documentation to the list too, and it's disappointing that none of the QuickStarts/hands-on-labs seem suitable for the current version of Visual Studio and Silverlight.


Dec 8, 2010 at 7:16 PM


Unity for Silverlight is a subset of Unity for .NET CLR. It doesn’t include support for interception yet (we are working on a new release of EntLib 5 Silverlight Integration Pack and that story is on the backlog). That is why the documentation and the hands-on labs for Unity should largely be applicable to Unity for Silverlight. The code for all lab exercises is shipped VS2008 proj files, but those should be automatically convertible to VS2010.

Reference documentation is not only available in CHM. It’s also available as HTML on MSDN: http://msdn.microsoft.com/en-us/library/ff663144.aspx 
I’ve also produced a print out of the doc to PDF if that helps you. Find it here: http://unity.codeplex.com/releases/view/31277#DownloadId=177468

This is not to say we are not working on improving our doc story. For the upcoming EntLib for Silverlight release, we are planning on having quickstarts and demos geared specifically to Silverlight LOB app development.

Thanks for your feedback and please continue letting us know what’s missing in our guidance. We are listening and acting on it!

Enterprise Library producer

Dec 9, 2010 at 11:48 AM

Thanks for the prompt response and also the PDF file :-) 

As I indicated in my original posting the QuickStart for Unity Silverlight 2 fails the VS2010 conversion process on a system that has only VS2010 and Silverlight 4 installed. 

This can be fixed by manually editing the StopLight.csproj file and changing the <PropertyGroup Condition="'$(MsBuildToolsVersion)' == '3.5'"> line near the top from 3.5 to 4.0 and the <TargetFrameworkVersion>v3.0</TargetFrameworkVersion> line to v4.0. If you makes these changes and then reload the project file the VS2010 conversion wizard will run without errors and the project will be avalable instead of displaying "Project unavailable".

Can you advise the likely timeframe for the upcoming EntLib for Silverlight release?





Dec 9, 2010 at 4:11 PM


Tentatively Spring 2011. You can find our roadmap and the announcement.

In a couple of days, I'll post a set of stories from the backlog for the community to vote on and to add to. I'll encourage you to take part in that voting and also help us spread the word.

Stay tuned.



Dec 9, 2010 at 6:17 PM

Thanks Grigori.

The roadmap doesn't meet the timescales I have on my current project, but will certainly be useful for future projects. 

Is there any chance of early visibility on the Logging interface?  I have looked at the ILoggerFacade interface that ships with PRISM but the interface is a little simplistic for our needs and so I'm "rolling my own". It would be good to get an early heads-up on the likely Ent Lib 5.0 interface so that a swap to use Enterprise Library 5 for Silverlight at some future time might be easier. 



Dec 9, 2010 at 7:15 PM

Yes, just like on previoius releases, we'll be doing biweekly code drops via codeplex.

Note, we are still spiking on this and exploring scenarios. Development will start in mid-January.

Dec 9, 2010 at 10:28 PM

Our current intention is to make the Entlib for Silverlight interfaces as close to the desktop interfaces as possible. We may have to leave stuff out to keep the size down, but the usage, class & interface names, etc. should remain the same.



Mar 7, 2011 at 10:16 PM

We've posted our first drop of Unity Interception for Silverlight. Take a look, provide feedback.