Further to Howard's post regarding our trials and tribulations whilst developing a Silverlight Alpha, app I wanted to share something that I encountered whilst using Blend, and although I don't really have a solution to the problem, it’s certainly worth being aware of as it took me a little while to get to the bottom of it when I first encountered it.
Background
the Silverlight site that we were developing was pretty image and animation heavy and as such, the approach I took whilst developing was to have the solution open in both VS 2005 (Orcas Beta 1) and in Blend 2 (May Preview). Additionally, we were using some controls that were based on the Sample Ui Controls that ship with the Silverlight SDK.
Problem 1
With this in mind, consider the following Silverlight page declaration and page definition:
<Canvas xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:SomeProjectName.Silverlight.Controls;assembly=ClientBin/ SomeProjectName.Silverlight.Controls.dll"
x:Name="LondonCallingTrackListing"
Loaded="Page_Loaded"
x:Class="SomeProjectName.Silverlight.App.LondonCallingTrackListing;assembly=ClientBin/TheClash.Silverlight.App.dll"
Width="1024" Height="768" Background="#00000000">
....
<!-- Some other stuff-->
<controls:ImageButton Source="Assets/Discography/closeRoll.png" x:Name="imageCloseRoll" Canvas.Left="831" Canvas.Top="109.5" Click="OnCloseClick" Visibility="Hidden" Opacity="0"/>
<controls:ImageButton Source="Assets/Discography/close.png" x:Name="imageClose" Canvas.Left="831" Canvas.Top="109.5" Opacity="0"/>
All pretty innocuous I'm sure you'll agree. So, assume I have finished (for now) using Blend to do the heavy lifting for the animations I'm working on (or whatever it was I was using Blend for in the first place) and decide to save - I would then flick back to VS 2005, reload and run. It’s at this point that I get an error stating that a parse error has occurred.
Error:
Silverlight error message
ErrorCode: 2252
ErrorType: ParseError
Message: AG_E_RUNTIME_MANAGED_ASSEMBLY_DOWNLOAD
XamlFile: LondonCallingTrackListing.xaml
Line:234
Position: 179
Upon inspection what I find is that my declaration:
<Canvas xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:SomeProjectName.Silverlight.Controls;assembly=ClientBin/ SomeProjectName.Silverlight.Controls.dll"
x:Name="LondonCallingTrackListing"
Loaded="Page_Loaded"
x:Class="SomeProjectName.Silverlight.App.LondonCallingTrackListing;assembly=ClientBin/SomeProjectName.Silverlight.App.dll"
Width="1024" Height="768" Background="#00000000">
....
<!-- Some other stuff-->
<controls:ImageButton Source="Assets/Discography/closeRoll.png" x:Name="imageCloseRoll" Canvas.Left="831" Canvas.Top="109.5" Click="OnCloseClick" Visibility="Hidden" Opacity="0"/>
<controls:ImageButton Source="Assets/Discography/close.png" x:Name="imageClose" Canvas.Left="831" Canvas.Top="109.5" Opacity="0"/>
Has been transformed by Blend to:
<Canvas xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:SomeProjectName.Silverlight.Controls;assembly=ClientBin/ SomeProjectName.Silverlight.Controls.dll"
x:Name="LondonCallingTrackListing"
Loaded="Page_Loaded"
x:Class=" SomeProjectName.Silverlight.App.LondonCallingTrackListing;assembly=ClientBin/TheClash.Silverlight.App.dll"
xmlns:SomeProjectName_Silverlight_Controls="clrnamespace:SomeProjectName.Silverlight.Controls;assembly=SomeProjectName.Silverlight.Controls.dll"
Width="1024" Height="768" Background="#00000000">
...
<!-- Some other stuff-->
< SomeProjectName_Silverlight_Controls:ImageButton Source="Assets/Discography/closeRoll.png" x:Name="imageCloseRoll" Canvas.Left="831" Canvas.Top="109.5" Click="OnCloseClick" Visibility="Hidden" Opacity="0"/>
< SomeProjectName_Silverlight_Controls:ImageButton Source="Assets/Discography/close.png" x:Name="imageClose" Canvas.Left="831" Canvas.Top="109.5" Opacity="0"/>
Note: Not only has Blend added a superfluous assembly reference, but it has also missed out a vital part of the path to that assembly, the ClientBin part and thus, causes the error mentioned earlier.
I'm not sure why this is happening and I'm sure that somebody else has had this and knows the reason and solution - if so I'd be grateful for a heads up. Equally, it’s not the biggest problem in the world, and in a simple app it’s pretty straight forward to understand the parse errors returned and head straight to the source of the problem. However, due to the way we had created and asynchronously loaded our pages it took me some time to identify what had happened between the time when I had a working app in Vs2005, made a tweak in Blend, saved (in Blend) and then ran it in Vs2005.
Problem 2
In the app that we were creating we had many pages that were largely the same, or at least the size, background and general layout was the same, and as such I decided that just copying the Silverlight pages from within the project explorer (in Blend) and then changing the bits that needed changing would be the quickest way to go. And here is when I encountered another small problem.
The Silverlight pages when created should have the following attributes:
Build Action: SilverlightPage
Copy to output: Do Not copy
Custom Tool: MSBuild:CompileXaml
...
The pages that I copied through Blend had the following attributes:
Build Action: Embedded Resource
Copy to output: Do Not copy
Custom Tool:
...
The result of this, as far as I can remember was that again I got runtime errors and it wasn't until I looked at the proj file to see what had happened that I noticed the difference. Again, this isn't a huge deal, as long as you're aware.