WcfDataPortal Exception

WcfDataPortal Exception

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


benedikt posted on Friday, May 13, 2011

Hello together!

I am trying Csla the first time now. I build a little Projekt with a IIS 7 hosted Wcf Dataportal. The client is a simple WFC client with following App.config:

 

  <appSettings>
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
    <add key="CslaDataPortalUrl" value="http://localhost/WcfHost/WcfPortal.svc"/>
  </appSettings>

 

I am using Csla 4.1.0.0, wsHttpbinding. The BO creation is managed by Factories. 

The communication between client and server over WCF seems fine. Stepping through it shows, that the object is created on the server and delivered to the client:

 

ObjectFactory code to create a cleaner_csla object:
            var obj = (Cleaner_Csla)MethodCaller.CreateInstance(typeof(Cleaner_Csla));
            MarkNew(obj);
            return obj;
But when i am trying to change something on the object, like setting the Id or the name of the object a WCF deserialization exception is thrown:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ws.lhotka.net/WcfDataPortal:CreateResult. The InnerException message was 'Error in line 1 position 2522. 'EndElement' '_raiseListChangedEvent' from namespace 'http://schemas.datacontract.org/2004/07/Csla.Rules' is not expected. Expecting element 'AddedNew'.'. Please see InnerException for more details. 
Found the same issue here, but there was no solution to this: http://forums.lhotka.net/forums/p/7957/38045.aspx#38045
Cloning the object directly after creation and editing works.

Thanks

RockfordLhotka replied on Friday, May 13, 2011

By default the clone operation uses the BinaryFormatter. The data portal will use the NetDataContractSerializer.

The two are almost identical, but it is possible that the NDCS is doing something different based on your object's data or something.

You can force CSLA to use the NDCS for cloning by setting the CslaSerializationFormatter app config file to "NetDataContractSerializer".

  <appSettings>
    <add key="CslaSerializationFormatter" value="NetDataContractSerializer"/>
  </appSettings>

Then try the clone and see if you can get a similar failure.

If that clone works, then the issue is that the byte stream is getting corrupted or truncated as it goes across the network, and you'll need to get out fiddler or turn on WCF tracing to see what's going on.

Copyright (c) Marimer LLC