This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I know this issue has been addressed before, but I I'v not seen a definitive Yes or NO as to whether this will be supported. I need to serialize a tree hierarchy of Entity's to XML, and get te fllowing error. {"Cannot serialize member 'Mindscape.LightSpeed.Entity.Errors' of type 'Mindscape.LightSpeed.Validation.ValidationErrorCollection', see inner exception for more details."} {"Mindscape.LightSpeed.Validation.ValidationError cannot be serialized because it does not have a parameterless constructor."} I'm using last nights build (2008-10-12), and no Bainary serialization cannot be used in this instance, and no it's got nothing to do with remoting. Is XMLserialization of entities going to be supported in the near future? Anthony |
|
|
Let me give you a definitive "yes." XML serialisation of entities is supported today, with the caveats Jeremy describes at http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=1038&PostID=2301. However, in trying to reproduce your issue, we discovered that the support described in Jeremy's post, although it worked in our ASMX scenario, did not work for explicit XML serialisation using XmlSerializer. We have committed a fix for this and it will be in nightlies dated 15 October 2008 and onward. Please let us know if you still see problems. The fix is that we now exclude the Errors collection from serialisation. (We believe this is appropriate because validation errors are not part of permanent state, but depend on business rules.) As a consequence, if you want to get the errors at the deserialiser end, you will need to re-validate the entity. Note also that ID is not part of serialised state. Deserialised entities will always be considered "new," and if attached to a unit of work and saved will have a new ID allocated for them. |
|
|
Perfect, I'm a happy man.
thx Anthony |
|
|
I am still having problems with the export of the model to XML. When I use the XmlSerializer, I get the message: Unable to generate a temporary class (result=1). When I use the DataContractSerializer it creates an xml file with only the private fields ? and no relations defined although I use the constructor with parameter for preserveObjectReferences ( DataContractSerializer ser = new DataContractSerializer(query.GetType(), null, int.MaxValue, false, true, null);)
Anybody has any idea?
|
|
|
I still can't serialize: I get the following error: I'm using Lightspeed 2.1 {"Unable to generate a temporary class (result=1).\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\nerror CS0200: Property or indexer 'Mindscape.LightSpeed.Entity.EntityState' cannot be assigned to -- it is read only\r\n"}
|
|
|
Here, you can try using this to write to xml:
public class LightSpeedXmlAccess
public static class LightSpeedUtility
|
|
|
That might be great for '1' entity, but I need to serialize serialize 15 levels in an object structure. |
|
|
We've been unable to reproduce the EntityState "Unable to generate temporary class" problem. Could one of you provide us with code (entity classes plus harness) to reproduce the problem please? Thanks! |
|
|
Our resident WCF wizard will write up the use of DataContractSerializer (and other serialisation considerations), but he is at a conference this week, so this probably won't come out until the beginning of next week. Apologies for the delay, but you'll get a much better answer from him than you would from me! |
|
|
Hi rvanhoornaar and antprog, We have been investigating the CS0200 error and this appears to be a bug in certain versions of the .NET Framework -- see http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=96882. (Entity.EntityState has a non-public setter.) It is fixed in 3.5 SP1. If upgrading to 3.5 SP1 is not an option for you or your customers, let us know and we will see what we can do. (Note that you do not need to *target* 3.x to get the fix; 3.5 SP1 modifies the 2.0 core assemblies, so it should fix the problem even for projects that target 2.0.) I wanted to mention another issue that you are likely to run into when using the XmlSerializer, namely that of circular references. The XmlSerializer always expands object references. It therefore does not allow circular references (because these would have to be expanded forever). This causes a problem when serialising LightSpeed entities with associations, because an association is always bidirectional (e.g. a Contribution has a Comments collection, and each Comment in that collection has a backreference to the Contribution) -- there is *always* a circular reference! You can get around this with strategically placed XmlIgnore attributes if you hand-code the entities (and know where you are starting from), but if you are using the designer, this won't work because your attributes will get overwritten when the designer regenerates the code. In this case check out the XmlAttributeOverrides overload of the XmlSerializer constructor which allows you to fake up XmlIgnore attributes at runtime. There are some other design issues to do with references, e.g. duplicate references (Contribution has Comments, each Comment has a Member, what if two Comments were left by the same Member?), but these go a bit further into the design arena, so I'll leave these for Jeremy to cover in his forthcoming post. |
|
|
Thank you, this solves my problem |
|