Track tasks and feature requests

In.net Framework 3.5 SP1, DataContractSerializer supports by-ref object graph serialization by using the standard xsd:ID/xsd:IDREF attributes. You can set the IsReference=true on your DataContract definition and serializer will generate XML elements with IDs/IDREFs attributes and will link them together rather embedding them inside each other. Well the only XML Serializer used and supported is the BCL's DataContractSerializer which as you know doesn't support XML Attributes. The only way to get the desired output is to return a string or a stream containing the serialized XML you want to return, however this means ServiceStack won't be able to provide other formats for it since it's returning an already serialized form. You must specify [DataMember] attribute on the property or the field of your Data Contract class to identify it as a Data Member. DataContractSerializer will serialize only those members, which are annotated by [DataMemeber] attribute. On the other hand you can reuse the DataContractSerializer for serialization of JSON. Whereas XmlSerializer is XML specific. Whereas XmlSerializer is XML specific. If you prefer using opt in (only serializing what you want) then DataContractSerializer might be just right for you. XmlSerializer vs DataContractSerializer: Serialization in Wcf Posted by Dan Rigsby on March 7th, 2008 The XmlSerializer has been in.Net since version 1.0 and has served us well for everything from Remoting, Web Services, serializing to a file, etc. However in.Net 3.0 the DataContractSerializercame along. And all of a sudden a lot of guidance suggests that we should use.

Join 40 million developers who use GitHub issues to help identify, assign, and keep track of the features and bug fixes your projects need.

Sign up for free See pricing for teams and enterprises New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments

commented Mar 3, 2016

The following code is not working can you please check.. What am I doing wrong here?

commented Mar 3, 2016

Protobuf-net needs to know numbers for each field you want to serialize. There are ways to make this semi-automated, but the easiest way would be to explicitly mark them:

That should fix it.

commented Mar 4, 2016

Datacontract serialization attributes of jesus christ

Well @mgravell , I'm afraid that won't work in my case. I was using a base class Microsoft.Xrm.Sdk.Entity . So for the DataContract and DataMember attributes I'm not able to change the Order parameter value. Then, what should I do? (Please consider the following example)

And there are some properties on Microsoft.Crm.Sdk.Entity class that ae marked with DataMember attribute without Order parameter setted and the class itself is marked with DataContract attribute.

So, it has to be fixed I guess; I mean there is no other way, right?

commented Mar 4, 2016

Well, in this scenario the first thing I'd note is that using implementation details (such as Microsoft.Crm.Sdk.Entity) in serialization layers is not a great idea - it creates a huge number of traps. Frankly, if serialization of an existing object model becomes non-trivial, the best approach is not 'fight the serializer' but rather 'create a simple DTO that fits the serializer perfectly'

As it happens, protobuf-net does have things like ImplicitFields that can help in some of these scenarios, but it only looks at the declaring type, not base-types - so it wouldn't pull from Entity. protobuf-net also has the ability to configure types manually, but that would require you adding code to your app-init. But to give an example broadly similar to yours:

Note here that the order of the members in Add defines their wire identity - so Foo is 1, Bar is 2, etc. Depending on your C# version, you may also wish to look at nameof rather than hard-coded strings:

Is any of that useful?

commented Mar 7, 2016

Actually, RuntimeTypeModel.Default.Add solution worked for me for most of the situations. But I couldn't solve 1 problem with this way: It doesn't serialize Attributes property: It's type is Microsoft.Xrm.Sdk.AttributeCollection. What can be the problem with collection types when using this trick. (Please consider the following example.)

commented Mar 7, 2016

Microsoft.Xrm.Sdk.AttributeCollection is basically a
Dictionary<string,object>, which protobuf-net is going to hate. The
protobuf format is designed to serialize models with a well-known shape /
format - which 'object' isn't. There is no good way to handle a
string-object map in protobuf; there are some bad ways, but that depends a
lot on what the actual values are in your scenario.

Datacontract Serialization Attributes Of Jesus

commented Mar 7, 2016

Well it's just a collection with items of type KeyValuePair<string, object>. Right? And KeyValuePair is just a struct with 2 properties: Key and Value. So what should I do about it?

And I think, on the contrary, Google.ProtocolBuffers supports map fields with version 3 and even with version 2.

C# Datamember Attribute

commented Mar 7, 2016

The problem isn't the map - protobuf-net would happily support
Dictionary<string,Project>, to use the example from your links; it is the
'object'. Protobuf wants to know what it is deserializing. So again: what
are the actual values?

On 7 March 2016 at 09:14, rebulanyum notifications@github.com wrote:

Well it's just a collection with items of type KeyValuePair<string,
object>. Right? And KeyValuePair is just a struct with 2 properties: Key
and Value. So what should I do about it?

And I think, on the contrary, Google.ProtocolBuffers supports map fields
with version 3
https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#map_field
and even with version 2
https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#map_field
.


Reply to this email directly or view it on GitHub
#146 (comment)
.

Regards,

Marc

commented Mar 7, 2016

Oh, I'm sorry for my bad understanding..

The 'object' is sometimes string, sometimes Microsoft.Xrm.Sdk.EntityReference. It's not a single fixed type. But even strings are not serializing..

commented Mar 7, 2016

But even strings are not serializing..

That is expected. It knows that in the general case it doesn't know how to
work with 'object', so it isn't happy to start trying, unless it has been
specifically configured to treat it as a string-string map. But
fundamentally, I would again simply suggest that anything based on this
much implementation details rather than data details isn't a good choice
for serialization
. The preference here (IMO) would be to create a DTO
model specifically intended for serialization, that represents the data
you want to serialize, rather than the active object model you happen to be
using at the timel

On 7 March 2016 at 14:32, rebulanyum notifications@github.com wrote:

Download software install openmeetings Nov 09, 2015  Apache OpenMeetings is an open source software used for online training, web conferencing, collaborative white board drawing and documents editing.This software is based on a number of open source tools like OpenLaszlo RIA framework and Red5 Media Server. The communication takes place in a virtual. Apache OpenMeetings is free webinar software that allows you to easily groups can. OpenMeetings for Windows 10 32/64 download free. A webinar is a presentation given via the internet. OpenMeetings is an open source solution that you are on a private server room can install to online webinars as possible, to. Oct 10, 2018  Install FFMpeg (with -enabled libmp3lame and libx264 options).You should get FFMPEG in an up to date copy! OpenMeetings is tested with FFMPEG Version 10.3 and latest. Nov 20, 2018  All downloads should be verified using the Apache OpenMeetings code signing KEYS, Here are the instructions changes: CHANGELOG.md. All versions are available for download as. OpenMeetings is a free open source browser-based software that allows you to set up instantly a conference in the Web. You can use your microphone or webcam, share documents on a white board, share your screen or record meetings.

Oh, I'm sorry for my bad understanding..

The 'object' is sometimes string, sometimes
Microsoft.Xrm.Sdk.EntityReference. It's not a single fixed type. But even
strings are not serializing..


Reply to this email directly or view it on GitHub
#146 (comment)
.

Regards,

Marc

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
d3nho.netlify.com – 2018