• Prism 2 (Composite Application Guidance for WPF & Silverlight) migrated to Silverlight 4 Beta

    Published by on November 20th, 2009 6:26 pm under Composite Application Guidance for WPF & SL, p&p, Patterns & Practices, Prism-v2, Prism-v2.1, Silverlight, Silverlight 4, Silverlight 4 Beta, Visual Studio 2010, Visual Studio 2010 Beta 2, Windows Presentation Foundation, WPF

    6 Comments

    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.

    image

    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:

    1. Replace “$(SilverlightVersion)” for “v4.0″.
    2. 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!!!

    Shout it

    kick it on DotNetKicks.com

    Tags: , , , , , , , , , , ,

    • Flex

      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!

    • drew

      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: 0x80131515)
      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)

    • Damian Schenkelman

      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

    • http://www.atomicwriter.com Victor Grippi

      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

    • http://www.atomicwriter.com Victor Grippi

      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

    • Johan

      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.

Archives

Categories