Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I did was create a serialization container which analyses it's contents to see which references are needed and is serialized separately:</p> <pre><code>[serializable] public class Container { private IEnumerable&lt;object&gt; data; public Container(IEnumerable data); public string[] GetFullyQualifiedReferences(); } </code></pre> <p>So you put whatever data you like in here, and you get a list of fully qualified assembly names, which you then store seperately.</p> <p>Assuming <code>Wibble</code> is the class that is serializing the Foo </p> <pre><code>public class Wibble : ISerializable { public string Agnostic { get { return agnostic; } } public void GetObjectData(SerializationInfo info, StreamingContext context) { //construct a container based on my data. Container container = new Container(new object[]{myFoo}); info.AddValue("RequiredReferences",container.GetFullyQualifiedReferences()); byte[] containerData = Serialize(container); info.AddValue("TypeUnsafeData",containerData); //store some safe typed versions of the context data, if necessary. info.AddValue("SafeValues", GetSafeValues()) } public Wibble(SerializationInfo info, StreamingContext context) { var requiredAssemblies = (string[])info.GetValue("RequiredReferences",typeof(string[])); if(AreAssembliesLoaded(requiredAssemblies ))) { //deserialise the container as normal } else { //instead, load the "safe" data that we previously stored. } } } </code></pre> <p>I know this doesn't make perfect sense given the illustration, but the illustration is a slightly imperfect abstraction of my implementation problem, but the solution should work for both (I know it works for my implementation!)</p> <p>You could go the next step and have a container in a container listing the specific required assemblies for any container, but that's not really necessary in this illustration.</p> <p>------Update-------</p> <p>There is a slight problem with this implementation as it stands, and that is if you update the contextual assembly version numbers, the deserializer will not find the old assembly. so, you either need to:</p> <p>Provide some sort of mechanism for allowing the deseralize code to see if it can find a modern version of the assembly and then query it, </p> <p>---or---</p> <p>Update the equality of the fully qualified name to not be sensitive to versioning.</p>
    singulars
    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.
    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