I need a little bit of help

I need a little bit of help

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


AKaplan posted on Saturday, January 21, 2012

I'm currently writing a Silverlight 4 app, and I'm getting an error that I don't understand. I'm trying to execute the following and it's getting this error in the debugging output. Can someone tell me what I am doing wrong and how to fix it?

 Public Sub btnHelp_Click()

            Bxf.Shell.Instance.ShowView(GetType(HelpView).AssemblyQualifiedName, String.Empty, New Help_ViewModel, "Main")

        End Sub

Step into: Stepping over method without symbols 'Bxf.Shell.Instance.get'

Step into: Stepping over method without symbols 'System.RuntimeType.AssemblyQualifiedName.get'

Step into: Stepping over method without symbols 'Designer.Help_ViewModel.Help_ViewModel'

Step into: Stepping over method without symbols 'Bxf.Shell.ShowView'

A first chance exception of type 'System.InvalidCastException' occurred in Bxf

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Step into: Stepping over method without symbols 'Bxf.Xaml.TriggerAction.CallMethod'

A first chance exception of type 'System.InvalidCastException' occurred in Bxf

Step into: Stepping over method without symbols 'MS.Internal.JoltHelper.FireEvent'

The program '[4440] chrome.exe: Silverlight' has exited with code 0 (0x0).

The program '[2304] w3wp.exe: Managed (v2.0.50727)' has exited with code 0 (0x0).

ajj3085 replied on Saturday, January 21, 2012

Is the application running ok otherwise?  Its normal for exceptions to be thrown caught and handled during the course of a running application. 

AKaplan replied on Sunday, January 22, 2012

Yes the application is running normal until I execute that line. When executed, the app goes blank, and I have to refresh the browser. If it's any constellation, the view is a child window instead of a usercontrol. 

AKaplan replied on Thursday, January 26, 2012

I still haven't been able to resolve this issue or even understand what I'm doing wrong. Can anyone please help?

Public Sub New

AddHandler presenter.OnShowView, Sub(view, region)

                                                 Select Case region

                                                     Case "Main"

                                                         MainContent = view

                                                     Case "Menu"

                                                         MenuContent = view

                                                     Case "Samples"

                                                         SampleContent = view

                                                     Case "Product"

                                                         ProductContent = view

                                                     Case "Error"

                                                         _errorClose = DateTime.Now.Add(New TimeSpan(0, 0, 5))

                                                         ErrorContent = view

                                                     Case "User"

                                                         UserContent = view

                                                     Case "Modal"

                                                         Dim cw As New ChildWindow

                                                         cw.Content = view

                                                         AddHandler cw.Closed, Sub() cw.DialogResult = False

                                                         cw.Show()

                                                     Case "Status"

                                                         _statusClose = DateTime.Now.Add(New TimeSpan(0, 0, 5))

                                                         If view IsNot Nothing Then

                                                             AppBusy = DirectCast(view, Bxf.Status).IsBusy

                                                         Else

                                                             AppBusy = False

                                                         End If

                                                         StatusContent = view

                                                 End Select

                                             End Sub

End Sub

 Public Sub btnHelp_Click()

            Bxf.Shell.Instance.ShowView(GetType(HelpView).AssemblyQualifiedName, String.Empty, New Help_ViewModel, "Modal")

        End Sub

RockfordLhotka replied on Thursday, January 26, 2012

You should understand that Bxf doesn't actually do anything beyond route the ShowView method call to your OnShowView handler.

The secret to almost all debugging is to put a breakpoint at the top of the OnShowView handler and step through it.

AKaplan replied on Friday, January 27, 2012

ok... I'm still stumped. Whats wrong with my handler?

AKaplan replied on Tuesday, January 31, 2012

ok I found the exact culprit in my problem.

 Dim vf As New Bxf.ViewFactory

            Dim v = vf.GetView(GetType(View.ProductCategoryListView).AssemblyQualifiedName, "productcategorylistViewSource", New ViewModel.ProductCategoryList_ViewModel)

            Bxf.Shell.Instance.ShowView(v, "Menu")

 

When I make this approach on the ShowView method, It says it is unable to cast Bxf.View to UserControl. How can I correct this?

 

RockfordLhotka replied on Tuesday, January 31, 2012

This whole thread should be in the Bxf forum at http://bxf.codeplex.com - it has nothing to do with CSLA...

Bxf assumes that views subclass UserControl. The assumption is that your entire UI is composed of UserControl subclassed views that are "hosted" or displayed in regions that are contained in things like a Windows, Page, ChildWindow, etc.

Copyright (c) Marimer LLC