Note that there are some explanatory texts on larger screens.

plurals
  1. POSerialize and deserialize Object with non standard constructor - protobuf-net
    primarykey
    data
    text
    <p>I have an object which </p> <ul> <li>does not have the Serializable attribute set</li> <li>Has properties, who's type, does not have the Serializable attribute set</li> <li>I do not have control over (meaning i cannot edit the class)</li> </ul> <p>I tried reading <a href="http://www.codeproject.com/Articles/240621/How-to-serialize-data-effectively-Custom-serializa" rel="nofollow noreferrer">THIS</a>, it talks about substitution classes to fix this when using <a href="http://www.sharpserializer.com/en/index.html" rel="nofollow noreferrer">Sharpserializer</a> but frankly, I don't understand how to do this when I don't know the properties of my object.</p> <p>are there some of serialization frameworks that can do this?</p> <p>Edit: I'm looking into protobuf.net I cannot figure out how to get it to work in my scenario though - Im hoping Marc will swing by to save the day? :) - I read <a href="https://stackoverflow.com/questions/17563554/how-do-you-configure-protobuf-nets-runtimemodel-default-to-support-serializing#comment27254551_17563554">this</a> which is the exact same problem as mine, but I'm still getting "Type is not expected and no contract can be inferred" when using </p> <pre><code>private static byte[] ClienToBytes(IScsClient client) { using (var memoryStream = new MemoryStream()) { RuntimeTypeModel.Default.Add(typeof(IScsClient), true).SetSurrogate(typeof(BinaryFormatterSurrogate&lt;IScsClient&gt;)); Serializer.Serialize(memoryStream, client); return memoryStream.ToArray(); } } </code></pre> <p>am I using the RunTimeTypeModel wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload