Prism 2 (Composite Application Guidance for WPF & Silverlight) migrated to Silverlight 4 Beta
November 20th, 2009
Most of you know that a Silverlight 4 Beta was released last Wednesday, after Scott Gu’s PDC keynote. If you are a Prism user, and if you are reading this there’s a high chance you are, you are probably wondering how this relates to p&p future plans. Well, Blaine has given us a brief idea of Prism’s future in this forum thread, so you might want to check it out.
On a related but different subject Fernando and I migrated the latest Prism release to Silverlight 4 Beta version & Net 4.0. A few minor changes needed to be done in the code (explained here), and some other in the .csproj files due to an issue we came up using the Silverlight migration wizard.
Migration Issues
After going through the migration wizard, you will notice that all Silverlight projects are not loaded. This is because they are still looking for the 3.0 installation directory instead of 4.0 as you can see in the picture below.
To fix this issue you need to edit your .csproj file and redirect it to the Silverlight 4 directory. The line that is related to this issue is the following:
<Import Project=“$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion) \Microsoft.Silverlight.CSharp.targets” />
Here you have two options:
- Replace “$(SilverlightVersion)” for “v4.0″.
- Modify any existing declarations of “SilverlightVersion“ in your file and update them to 4.0. Take into account that some of them might be using the “FrameworkVersion”. The code below shows this situation:
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
Prism Migrated Download
If you want to save some time, you can download the CAL, Quickstarts and RI from here. The code is provided “AS IS” with no warranties and confers no rights and is shipped under the “works on our machine” license.
Have fun coding in Silverlight 4!!!

November 22nd, 2009 at 6:41 pm
Prism 2 (Composite Application Guidance for WPF & Silverlight) migrated to Silverlight 4 Beta…
Thank you for submitting this cool story - Trackback from DotNetShoutout…
November 22nd, 2009 at 6:59 pm
[...] Damian Schenkelman’s Blog » Blog Archive » Prism 2 (Composite Application Guidance for WPF &am… blogs.southworks.net/dschenkelman/2009/11/20/prism-2-composite-application-guidance-for-wpf-silverlightmigrated-to-silverlight-4-beta – view page – cached Prism 2 (Composite Application Guidance for WPF & Silverlight) migrated to Silverlight 4 Beta [...]
November 24th, 2009 at 6:03 pm
[...] This post was Twitted by danvanderboom [...]
November 25th, 2009 at 3:56 pm
I found your download doesn’t change the target framework to v4 on the Silverlight side of things.
I had to manually go in and change this myself.
Thanks for the update!
December 17th, 2009 at 4:37 am
Hi Damian,
when i try to build the solutions you have provided, i get this erros:
The “ValidateXaml” task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly ‘file:///C:\Documents and Settings\n36\Desktop\CRM\Silverlight\EmailsModule\Bin\Debug\Microsoft.Practices.Unity.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0×80131515)
File name: ‘file:///C:\Documents and Settings\n36\Desktop\CRM\Silverlight\EmailsModule\Bin\Debug\Microsoft.Practices.Unity.dll’ —> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask task)
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask task)
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
December 17th, 2009 at 6:04 am
Hi Drew,
I have not been able to reproduce your issue, but based on the exception it is probably related to the fact that the assemblies are not being run in a full trust environment (since they were downloaded from a remote location).
As this link provided in the exception explains:
“In the .NET Framework version 3.5 and earlier versions, if you loaded an assembly from a remote location, the assembly would run partially trusted with a grant set that depended on the zone in which it was loaded. For example, assemblies that were loaded from a Web site were loaded into the Internet zone and granted the Internet permission set. In other words, they executed in an Internet sandbox.
In the .NET Framework version 4 Beta 2, by default, you must either explicitly create a sandbox in which to run those assemblies, or run them in full trust. The element lets you specify that the assemblies that run partially trusted in earlier versions of the .NET Framework are to be run fully trusted in the .NET Framework 4 Beta 2.”
That same link explains a way to give permissions to the assemblies and be able to run them correclty.
I hope this helps,
Damian
January 15th, 2010 at 7:16 pm
Thanks for this article,
But has anyone actually got this to work in SL4 VS2010 beta 2? Not talking about loading project files, actually dynamically injecting a view into a silverlight application.
I added Prism support to my Silverlight business app, basically a navigation app with WCF RIA services support but cannot get a very simple piece of injected xaml to show up in the UI.
Any suggestions would be greatly appreciated.
BTW, the way I fixed Drew’s problem above was to find the assembly in question, right click on it, then remove the security block on the network obtained file. Presto, it loads fine without the annoying exception message.
Thanks in advance,
Victor
January 15th, 2010 at 11:32 pm
Damian,
I was able to get this to work, so disregard my previous post. I had simply set the background color in xaml for the main shell grid and this overrided anything I was injecting into the view. It works fine.
Victor
February 2nd, 2010 at 9:02 pm
To Drew regarding the The “ValidateXaml” task failed unexpectedly….error and others struggling with it.
Go to the specific dll, in this case on your machine at C:\Documents and Settings\n36\Desktop\CRM\Silverlight\EmailsModule\Bin\Debug\Microsoft.Practices.Unity.dll’
Right click -> Properties. You might see that the file is Blocked (a new thing)…just unblock the file and it will work.