There is a known issue with WCF RIA Services V1.0 SP2 RC’s Business Application project template.  The issue only surfaces in Silverlight 5, and there’s an easy way to fix it.  We determined the root cause of this issue after it was too late to fix it in time for the RC release, but the correction is in place for the RTW (final) release of SP2.

This bug surfaces after you create a new project after installing RIA Services SP2, using the Business Application project template, and then an end user registers or logs in.  After completing the registration/login process, the entire application is disabled.  You can see the Home, About, and logout buttons are disabled, and nothing is clickable.

image

If you change the project to target Silverlight 4, the problem goes away.  This made us think the problem was in the Silverlight runtime or SDK, but after the Silverlight team investigated it, the root cause ended up being in the project template within the code we put in place to help you get started.

It boils down to the LoginRegistrationWindow.xaml.cs file that is included in the template under the Views\Login folder in the Silverlight project.  Within that file, the OnOpened method from ChildWindow is overridden:

Code Snippet
  1. /// <summary>
  2. /// Ensures the visual state and focus are correct when the window is opened.
  3. /// </summary>
  4. protected override void OnOpened()
  5. {
  6.     this.NavigateToLogin();
  7. }

 

The problem is that in this override, the code does not call base.OnOpened().  When targeting the Silverlight 4 SDK, this just happens to work out okay and the screen gets re-enabled, but when targeting the Silverlight 5 SDK, a change to ChildWindow makes this misuse lead to a disabled screen.  By simply adding base.OnOpened before this.NavigateToLogin(), the problem goes away.

Code Snippet
  1. /// <summary>
  2. /// Ensures the visual state and focus are correct when the window is opened.
  3. /// </summary>
  4. protected override void OnOpened()
  5. {
  6.     base.OnOpened();
  7.     this.NavigateToLogin();
  8. }

 

With that fix in place, you can register/log in and the app will return to normal.  This same problem exists for the VB version of the template. You would need to a call to MyBase.OnOpened() to fix the problem.  Here’s what the Home, About, and logout links will look after applying the fix.

image

Technorati Tags: ,