Problems with pure CSLA for Silverlight 3.7.0 and Silverlight 3.0 installations

Problems with pure CSLA for Silverlight 3.7.0 and Silverlight 3.0 installations

Old forum URL: forums.lhotka.net/forums/t/7411.aspx


Gareth posted on Thursday, August 06, 2009

Hi Rocky, firstly congrats on your Silverlight video series. It's been very informative and useful. I've only got the last video to watch now!
In the meantime I thought I'd start looking at some of the demo projects on my machine.
Now I've come into CSLA and Silverlight at version 3.0 and the problem is none of the demos actually work because the System.Web.Silverlight assembly no longer exists (it was removed purposely by MS).

So the .aspx page reference to the assembly fails. This has to be removed.

(How do I put ASP code segments in these posts??)

Also the line:

<asp:Silverlight ID="Xaml1" runat="server" Source="/ClientBin/Demo.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />


...no longer works in pure Silverlight 3 (it probably works okay if you had Silverlight 2 and then installed 3 on top!).

In Silverlight 3 it has to be replaced with:

<object ID="Xaml1" type="application/x-silverlight" Width="100%" Height="100%">
<param name="Source" value="/ClientBin/Demo.xap" />
<param name="minRuntimeVersion" value="3.0.40624.0" />
</object>


So far so good. I got the demo to run, but on selecting "Add Product" I get various exceptions and things are just not working.

Any chance you could review your demo code to work with pure Silverlight 3 installations?

There is a whitepaper from Microsoft about it here: http://go.microsoft.com/fwlink/?LinkId=153377

Regards,
Gareth.

RockfordLhotka replied on Thursday, August 06, 2009

It is on my to-do list :)

RockfordLhotka replied on Thursday, August 06, 2009

Though I am curious about the exceptions you are getting? I've run several of the demos underSL3 without problem (other than the <object> tag issue).

Gareth replied on Thursday, August 06, 2009

Hi Rocky, thanks for getting back. With regard to the exceptions, once the app is running and the main screen appears with the menu options down the left hand side (Add Product, Show Product List, etc..).

If I click "Add Product" I get this:

Unhandled Error in Silverlight 2 Application Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)\n at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()\n at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.OnAncestorDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.NotifyDataContextChanged(DataContextChangedEventArgs e)\n at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)\n at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)\n at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent)

On continuing past that the form appears. I enter an Id of "A123" and Name "Gareth". The Red error dot stays by Id and hovering over it reports "Could not load file or assembly 'Csla, Version 3.7.0.0, Culture="neutral"......

Also there is no existing data in any of this obviously because I have no database - where do I get the source database from, or have I missed it?

Gareth.

RockfordLhotka replied on Thursday, August 06, 2009

Most of the demos have no database, instead relying on mock data.

I think only #8 has an actual database because it is for the data access video segment. That demo uses a SQL Express database that is in the App_Data folder where the data portal is hosted.

The exception you are getting is due to some change in SL3 that is breaking the PropertyStatus control. This is something I'm actively working on (with help from another person on the forum from a different thread).

Debugging the issue is turning out to be very difficult, because the exception occurs in the SL runtime, not in my code. I'm sure the problem is somewhere in my code - and after a few hours of slowly commenting out bits of code I think I've narrowed it down to just a half dozen possibilities... Nasty...

RockfordLhotka replied on Thursday, August 06, 2009

Regarding the exception you are getting:

I believe I resolved the issue and the fix is in the 3.7.x branch in svn.

I still don't fully understand the nature of the issue, but it seems that the XAML visual tree may not be entirely stable when PropertyStatus is initially rendered. In other words, I think the visual tree is changing out from under PropertyStatus as it is being loaded - an apparently new behavior of SL3.

My resolution may or may not be a real fix. As the control loads, it now bypasses the method that attempts to resolve the relative path to the UI control to be manipulated for authz purposes. All my test apps appear to work fine with this change, but I am suspicious that there might be some edge case where it won't work properly now.

In any case, the PropertyStatus control is in the middle of a facelift for CSLA .NET 3.8 and I'm hoping to entirely eliminate this issue with the redesign (and grant more power to the XAML designer).

RockfordLhotka replied on Thursday, August 06, 2009

Also, I put the updated demo code on http://download.lhotka.net - though I still need to get a refresh of 3.7.1 online with the PropertyStatus fix, as that's rather important.

But at least the updated sample projects are all online.

Gareth replied on Friday, August 07, 2009

Great stuff. Thanks Rocky! I've almost got my first SL3 with CSLA test app working...

Cheers,
Gareth.

Copyright (c) Marimer LLC