I have a .Net 4 solution using Silverlight 5 and CSLA 4.3. The included projects:
- MyProject (silverlight project that contains silverlight screens)
- MyProject.Web (WCF project)
- Library (contains csla business objects. Referenced only by MyProject.Web)
- Library.Sl (contains links to existing business objects in Library. Referenced only by MyProject)
I have configured the silverlight UI project (MyProject) to point to a WCF Portal/host via a service on the WCF Project (MyProject.Web). I can browse the service by finding the .svc file, right clicking -> view in Browser.
When the silverlight page loads up, I run the following code:
DataPortal<MyMobileObjItem> dp = new DataPortal<MyMobileObjItem>();
dp.FetchCompleted += HandleReturnedArgs;
When this code runs, I am getting the following error in the callback EventArgs: System.InvalidOperationException: Object type or assembly could not be loaded (MyProject.Library.MyMobileObjItem, MyProject.Library.Sl...
I don't understand why the error on the server has the "MyProject.Library.Sl" namespace in the error. The only place that namespace exists is in the project reference for the silverlight project, and this error is coming from the server!?
I downloaded the CSLA source so I could step through and see that the Csla.Server.Hosts.Silverlight.WcfPortal.Fetch() method is passed a criteria object with a TypeName of MyProject.Library.MyMobileObjItem, MyProject.Library.Sl...
Again, why is this receiving the silverlight linked project namespace? The MyMobileObjItem object that should be requested doesn't include the ".Sl" namespace.
I am at the end of my rope - any help would be appreciated. Thanks in advance
The assembly names and namespaces for Net and SL must be identical for serialization to work.
So if your Net assembly is called MyProject.Library the that must also be the name of the SL library., not MyProject.Library.Sl...
Hi Jonny, thanks for the response but I'm not sure what assembly name you are talking about.
The example projects for CSLA always seem to have a "MyProject.Sl" or a "MyProject.Client" silverlight class library project that contains no code at all, just links to the mobile objects (.cs files, in my example MyMobileObjItem.cs). So MyMobileObjItem.cs lives in MyProject.Library, and is added as an existing link in MyProject.Library.Sl project.
In the example projects, this .Sl project is referenced by the Silverlight UI and the example projects all work, so I am not sure what I am doing different.
I never define a namespace of "MyProject.Library.Sl" anywhere - its just an empty project that links files. The classes in this project do NOT have that namespace, they don't even live in that project and since they are links their namespace in unchanged and the same in both projects.
Can you elaborate on what I am doing wrong?
I have also tried deleting the .Sl project and linking the cs file directly in the Silverlight UI project (MyProject). The only change I see with this is that instead the error contains the namespace is MyProject, not MyProject.Library.Sl.
The name must be the same in both Net and SL.
I assume that your SL assembly name is now MyProject.Library.SL...dll
You must change the assembly name in "Project - Properties" on the SL project to be the same as the .Net project.
If you look at the CSLA source source and assemblies you should see that CSLA has
.NET : Csla.dll
And in the source the SL project name is Csla.Silverlight and the assemly name in the project properties is just Csla - telling the C# compiler that the compiled assembly should be named Csla.dll.
But why is name should be identical??? I mean we can import the required namespaces.
The fully qualified name transferred on the wire and used on the server by the deserializer to create instances of classes contain
Which is why both namespace and assembly name must be identical on both runtimes.
For more info read about AssemblyQualifiedName:
Thanks so much, if I change the namespace of my .Sl project to match that error goes away.
Copyright (c) Marimer LLC