Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum

CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Issue with Silverlight with bxf in CSLA 4.0 factory model with fetching data

    rated by 0 users
    This post has 9 Replies | 2 Followers

    Not Ranked
    Posts 3
    devbcorleone Posted: Wed, May 15 2013 10:41 AM
    My Dev team is having issues to incorporate Silverlight with Bxf in the CSLA 4.0 Factory Model, that has to call the wcf to fetch the data from database.

    Has anybody faced similar issues? Any help in this regard is appreciated as we are hitting the wall at this time!
    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Wed, May 15 2013 4:32 PM

    What is the problem here? Is it Bxf or CSLA related?

    Which version of CSLA 4 do you use?

    There is no problem in using the CSLA 4 Factory model in Silverlight or WinRT in an "edge" application that calls web services asyncronously provided that you use the asyncronous call to DataPortal. 

    Can you provide us with some sample project to show the problem?

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Thu, May 16 2013 12:56 AM

    If you are using CSLA 4-3 (or older CSLA 4) look at this post for using the callback:

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    Posts 3

    We are evaluating CSLA.NET for a Silverlight Application using MVVM Pattern.

    We are facing problem to fetch the data from WCF Data portal channel using factory implementation model.

    Here is a link to solution that demonstrates the issue.

    We are using CSLA.NET 4.3 release.

    I Would appreciate any help that is offered.


    Top 100 Contributor
    Posts 80
    Todd Haehn replied on Fri, May 17 2013 11:16 AM

    I would suggest you get Rocky's video series on CSLA MVVM and follow along with the examples.  You should start with his sample project and work your own stuff into it.  I started with that and added the factory loader and eventually moved from BXF to Caliburn with MEF for the front end. 

    I was able to get farther down the road with your project by moving the WcfPortal.svc and the Web.config (with modifications) from the TestAppWCF project intot he TestAppWeb project.  When I got that far I received serialization errors on your business objects.

    I change dthe WcfPortal to:




    @ServiceHost Service="Csla.Server.Hosts.Silverlight.WcfPortal"  %>

    and in the web config I replaced the servicemodel section with:


        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>


          <service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">

            <endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal" bindingConfiguration="BasicHttpBinding_IWcfPortal">


                <dns value="localhost"/>







            <behavior name="returnFaults">

              <serviceDebug includeExceptionDetailInFaults="true"/>


            <behavior name="WcfPortalBehavior">

              <serviceMetadata httpGetEnabled="true"/>

              <serviceDebug includeExceptionDetailInFaults="true"/>






            <binding name="BasicHttpBinding_IWcfPortal" closeTimeout="00:10:00"

             openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"

             maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

              <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"

               maxBytesPerRead="2147483647" />


                <transport realm="" />






    Change the project to use the local IIS server and change the app.xaml.cs call to:

    sla.DataPortalClient.WcfProxy.DefaultUrl = new Uri(Current.Host.Source, "../WcfPortal.svc").ToString();

    These are settings that I use. I also remove the two lines:

        <add key="CslaWriter" value="Csla.Serialization.Mobile.CslaBinaryWriter, Csla"/>

        <add key="CslaReader" value="Csla.Serialization.Mobile.CslaBinaryReader, Csla"/>


    from the web config (I don't have them in mine). Not necessarily all necessary changes, but that's how I do it.





    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Fri, May 17 2013 11:17 AM


    There's at least 2 important mistakes.

    1. The BusinessLibrary in SL and .NET - MUST HAVE THE SAME ASSEMBLY NAME AND NAMESPACE to be compatible in serializer.
    2. The ObjectFactory MUST RETURN THE BUSINESS OBJECTS -  NOT DTO Objects.

    I really recommend the Using CSLA 4 Ebooks  and the http://download.lhotka.net/UsingCsla4-05/UsingCsla4-05-WPF-SL.pdf is spot on for this application.

    Your factory DAL  should look somewhat like this:

        public class EmployeeDal : Csla.Server.ObjectFactory
            private Employees Fetch()
              var result = new Employees();
              result.AddRange(from r in MockDb.Employees
                              select new Employee
                                  EmployeeID = r.EmployeeID,
                                  FirstName = r.FirstName,
                                  LastName = r.LastName
                return result;

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Fri, May 17 2013 11:22 AM

    I have some questions to your architecture as well.

    • Do you want to use CSLA in Edge mode (SL client only) and call WCF Services from SL client or
    • Use NTier deployment and remote dataportal where .NET code call WCF services and/or access databases?

    As of the code you posted you have a N-tier deployment where the NET Service may call WCF or access databases AND RETURN BUSINESS OBJECTS.

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 100 Contributor
    Posts 80
    Todd Haehn replied on Fri, May 17 2013 11:41 AM

    Oh, and I forgot to add, that I added the DLLs for the Business Objects to the web project and set it as the startup project.

    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Fri, May 17 2013 5:17 PM

    Next problem is your use of the ViewModel.

    I updated the EmployeeList viewmodel to be just this code:

        public class EmployeeList : ViewModel<CSLASilverlightTestApp.Library.Employees>
            public EmployeeList()

    And changed the data grid datacontext to the Model property of the ViewModel:

            <sdk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=Model}" 
                      Name="modelDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected">
                    <sdk:DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=EmployeeID}" Header="EmployeeID" IsReadOnly="True" Width="SizeToHeader" />
                    <sdk:DataGridTextColumn x:Name="FNameColumn" Binding="{Binding Path=FirstName}" Header="FirstName" Width="SizeToHeader" />
                    <sdk:DataGridTextColumn x:Name="LNameColumn" Binding="{Binding Path=LastName}" Header="LastName" Width="SizeToHeader" />

    As you BusinessObject  (ie ViewModel.Model ) already is the list you want.

    Then I would get the list of 4 employees shown correctly.

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    Posts 3

    Thank JonnyBee and Todd for all of your help!

    Page 1 of 1 (10 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems