I discovered these serialization problems first hand by writing this CodeProject article (go to the section "Loading a directory from disk" about halfway down).
Basically I am serializing something with an ASP.NET application - and the serialized data could not be read after the IIS application restarted (due to all the dynamic compilation / temporary assembly cache / etc, which ASP.NET does)! Oh!
, - , ,
h4octhiw, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null
, , , , "-". ( , ) (, "" )... ..
, ( ). System.Runtime.Serialization.SerializationBinder: .
public class CatalogBinder: System.Runtime.Serialization.SerializationBinder
{
public override Type BindToType (string assemblyName, string typeName)
{
string[] typeInfo = typeName.Split('.');
string className=typeInfo[typeInfo.Length -1];
if (className.Equals("Catalog"))
{
return typeof (Catalog);
}
else if (className.Equals("Word"))
{
return typeof (Word);
}
if (className.Equals("File"))
{
return typeof (File);
}
else
{
return Type.GetType(string.Format( "{0}, {1}", typeName,
assemblyName));
}
}
}
BindToType "" , . typeName, assemblyName, , , , SerializationBinder, , , , "" .
FYI, "" :
System.Runtime.Serialization.IFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Binder = new CatalogBinder();
object deserializedObject = formatter.Deserialize(stream);