I am new to Silverlight and CSLA and I need to get an example project working. I have both Lhotka's 2008 book on CSLA, as well as the Silverlight ebook + example project it comes with.
I thought it would be fairly simple to create a Silverlight 5 MVVM Light project that grabs a CSLA 4.3 object through the Data Portal (data portal/channel adapter configured to use WCF) but can't get a CSLA object back from the Server.
NOTE: If I take CSLA out of the equation and just use Linq to SQL or Entity Framework and a WCF RIA Service call I can grab objects from the server and display them in silverlight just fine, but as I can't use that on this project I must get CSLA to work.
My steps:
Added a service to the .Web project
<% @ServiceHost Service="Csla.Server.Hosts.Silverlight.WcfPortal" %> .
Referenced the Service in my App.xaml Application_Startup method in the SL project
Csla.DataPortalClient.WcfProxy.DefaultUrl = "http://localhost:14790/Services/MyTestCslaSilverlightWcfService.svc"; .
Added a simple CSLA Business layer project (MyProject.CSLA) that has one set of test objects (MyMobileObjItem.cs, MyMobileObjItemList.cs)
Added two more projects (MyProject.CSLA.Client and MyProject.CSLA.Server). The .Client project is a Silverlight class library, the .Server is a class library. I then linked all my CSLA objects (add existing reference, add as link) plus all necessary references (csla/csla silverlight dlls). On MyProject I add a reference the .Client project and on MyProject.Web I add a reference to the .Server project.
Now I should have a working project, and want to get an item or a list of items back from the server. In my main ViewModel in the constructor I have tried two different things. When I use
MyMobileObjItemList.GetAllAsync(HandleReturnedArgs);
the callback method EventArgs have an error "System.IO.FileNotFoundException: Could not load file or assembly "MyProject.CSLA.Client". I find this weird since the Silverlight app has a reference to this project, and the MyProject.Web shouldn't need the .Client reference since it has the .Server reference.
When I use
DataPortal<MyMobileObjItemList> dp = new DataPortal<MyMobileObjItemList>();
dp.FetchCompleted += HandleReturnedArgs;
dp.BeginFetch();
the callback method EventArgs have an error "System.InvalidOperationException: Object type or assembly could not be loaded (MyProject.CSLA.MyMobileObjItemList, MyProject.CSLA.Client".
I am not sure where either of these errors are happening (on the client or server?) Since it is a Csla.DataPortalException I assume it is a server error.
I am not sure how to do a simple call or if this is the correct way of going about things as all the examples I can find don't do it this way and seem unclear to me.
I know this is a lot of pieces to fit together and it may be hard to concisely give an answer, but I really would appreciate help (code, link to download example etc.)
QUESTIONS:
To fix the error error I changed the assembly and default namespaces for my .Client and .Server projects to exactly match the .CSLA project (set in project properties)
See this forum discussion for more info