System.IO.FileNotFoundException: Could not load file or assembly
Opened this issue · 1 comments
Following code ends by System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Drawing' or one of its dependencies. The system cannot find the file specified.'
var serializer = new Hyperion.Serializer();
byte[] serialized;
using (var ms = new MemoryStream())
{
serializer.Serialize(new System.Drawing.Point(10,15), ms);
serialized = ms.ToArray();
}
serializer = new Hyperion.Serializer();
using (var ms = new MemoryStream(serialized))
{
var res = serializer.Deserialize(ms);
}
It is because version, culture and public key of this system assembly is not stored in serialized data.
Only text "System.Drawing.Point, System.Drawing" for type is serialized.
Point of issue can be seen in following code:
var type = Type.GetType("System.Drawing.Point, System.Drawing"); // returns null
var type2 = Type.GetType("System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); // returns Point type
How to store more details for serialization / deserialization process? It would be fine if complete type definition would be serialized and if unable to deserialize more general approach would be used (omitting version, public key)
Thanks for advice.
Experience the same problem but with System.Windows.Media.Imaging.CachedBitmap