 |
|
 |
Hi
first of all, great article.
As stated in:
Is there any workaround for that issue ?
Best
|
|
|
|
 |
|
 |
Hi,
First off, this is an absolutely fantastic article on serialization.
I have a question regarding serialization attributes though. Does your implementation support: OnSerializingAttribute, OnSerializedAttribute, OnDeserializingAttribute, and OnDeserializedAttribute?
If not, how easy would it be for me to add such functionality?
Many thanks,
Lea Hayes
|
|
|
|
 |
|
 |
Hi, thanks for the article. Would you expect to be able to serialize an array of bytes? It doesn't seem to work correctly for me. (It appears to write the full array n times, where n is the length of the array. It is then unable to deserialize this.) Thanks, Dan [Serializable] public class Child : ISerializable { private byte[] _data; //..standard get/set properties and default constuctor protected Child(SerializationInfo info, StreamingContext ctxt) { Data = (byte[])info.GetValue("Data", typeof(byte[])); } public void GetObjectData(SerializationInfo info, StreamingContext ctxt) { info.AddValue("Data", Data, typeof(byte[])); } } Dan
|
|
|
|
 |
|
 |
Hi
how can i serialize my object to xml without xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
in my root tag.
tanx
@liCarryMe
|
|
|
|
 |
|
 |
Hi,
Any hints why it's not working. The class looks like this
[Serializable]
public class DataStore
{
#region fields
string _name;
string _location;
#endregion
#region public interface
public string Name { get { return _name; } set { _name = value; } }
public string Location { get { return _location; } set { _location = value; } }
#endregion
}
When I remove the ISerializable implementation in the provided demo class it throws an exception as well during the deserialization process.
FormatterServices.GetSerializableMembers dos return the private fields instead of the public string properties, but the private fields don't count and so nothing gets serialized, is this .net 3.0 related?
|
|
|
|
 |
|
 |
Hi there,
It is a great idea to implement an XmlFormatter. Exactly what is missing. I worked a bit with your code and figured out that it cannot compete with the XmlSerializer. I am working with serializing an object structure that was generated from a XSD file. XmlFormatter can only serialize the root node which is not sufficient. Also using the FormatterServices.GetSerializableMembers in your GetMembersMethod does not return any of the public properties of the generated classes.
Thanks, Peter.
|
|
|
|
 |
|
 |
Hello Patrick,
first of all I would like to congratulate you for this implementation.
I would like to use it but unfortunately in my case, I am working with IList (in fact ICollection), and as you mention into other posts it is not working yet.
Do you know when you think something would be available for this case?
If you have not too much time to work on this, would you please highlight me the main areas from the code I should look after in order to implement it??
Many thanks, and still great initiative.
Laurent an ex-colleague from CGEY.
|
|
|
|
 |
|
 |
I would be very interested in a version supporting generics, if it would be possible for you to post that. Or maybe just some high-level pointers on what had to change.
|
|
|
|
 |
|
 |
Hi, Thanks for the article.
Have you tried to use your class to serialize classes that contain generics as member classes? While working on a project I ran into an issue with the SOAP formatter (throws an exception: does not support generics). I had to resort to the binary formatter.
Oh BTW, Microsoft is releasing an XMLFormatter class as part of version 3.0 of the CLR. I am not sure how people feel about this but IMHO name clashing with MS will as a minimum cause someone some confusion if they think your class is MS's. Yes I know using namespaces will keep'em separated. But if I was scanning a code file I am not sure I would spot the nuance of a using statement separated from the use of a class name XMLFormatter, by god only knows how many lines of code.
Maybe the best thing to do would be to not use your namespace in the using section of the file, but explicitly name the containing namespace when the class is used. For example:
MyCustomXMLFormatter.XmlFormatter serlizer = new MyCustomXMLFormatter.XmlFormatter()
instead of
XmlFormatter serlizer = new .XmlFormatter()
any thoughts?
Keith
|
|
|
|
 |
|
 |
Hi Keith,
Sorry for the late reply. Yes, we have tried our formatter with classes that contain generics and gues what? That did not work . However, at this point we do have a version that does support Generics, besides other improvements on how to work with arrays and lists.
I cannot promise to post it right away, since we are on a very tight time schedule, but it will be posted when time permits. If you are really in need of this class, you can email me and I will send it back to you in rar format.
About the naming, I did not know yet that the 3.0 version of the .NET framework will contain a XmlFormatter, nor it's capabilities. Does the XmlSerializer still exist? Or is it simply renamed? These are things we cannot anticipate on and therefore are not within are scope. The class is simple to rename though, like the article said, it is free to use and improve.
Although named Framework 3.0, as far as I know it is still 2.0 extended with the libraries needed for the new programming model for Windows Vista. How and what is still very confusing.
|
|
|
|
 |
|
 |
Yes, the XMLSerializer will still be there. The XMLFormnatter is much like the binary formatter in its functionality. But I have not studied its details. And yes, the whole 2.0 vs 3.0 is a tad confusing. The new XMLFormatter came from the Indigo, aka WCF extensions...
Keith
|
|
|
|
 |
|
 |
Which basically is what we have done. De BinaryFormatter and SoapFormatter both implement IFormatter, which is what we have done.
If the XmlFormatter will be introduced in 3.0, our formatter will not be needed anymore. Until that time, we will use it.
Patrick
|
|
|
|
 |
|
 |
Since the title of this article is about a XMLFormatter provider for serialization, I had expected some discussion about it's implementation. The code in the article is really just an example on how to use the XMLFormatter.
|
|
|
|
 |
|
 |
I understand your expectations, for which I apologize on forhand. However, I just posted this code (and some text on how to use it) as an appendix to the article published in the .NET magazine article. We did not wanted to withheld the formatter for the public, so we just posted it as it is.
At this time, project pressure prevents us to find time to explain the code in depth in an article. Although some comments are made in the code, I do understand that it could be hard to understand its inner workings. We plan to publish a improved version in november when things come to a rest.
I'm sorry for the inconvinience.
|
|
|
|
 |
|
 |
No problem. I look forward to the update. Thanks.
|
|
|
|
 |
|
 |
It would be great if you included some benchmarks comparing the performance of your XmlFormatter with XmlSerializer (both with and without sgen).
|
|
|
|
 |
|
 |
Hi,
I will try to post some benchmarks showing the performance of the XmlFormatter compared to the XmlSerializer.
Thanks for your suggestion.
|
|
|
|
 |
|
 |
About your code formatting...
We made the buttons on the screen look so good you'll want to lick them. Steve Jobs
|
|
|
|
 |
|
 |
Instead of only criticizing a minor aspect of the code, why don't you provide a feedback to the author about the behind concept of his project ?
I think that articles on serialization are so important because the whole argument is more complex than it can appear, so every attempt on opening new doors is welcome.
Formatting issues are not meaningless, but neither that important to make them the only argument of a post (also considering that every team/programmer has his own formatting style, regardless or not to formatting good practises).
Thanks to the author for his article, he proposed an interesting approach to the the problem
|
|
|
|
 |
|
 |
Hi NinjaCross,
You are welcome. I hope it can be of use to you.
|
|
|
|
 |