Hyperion icon indicating copy to clipboard operation
Hyperion copied to clipboard

System.IO.FileNotFoundException: Could not load file or assembly

Open jakubbukaj opened this issue 4 years ago • 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.

jakubbukaj avatar Oct 13 '20 11:10 jakubbukaj

Experience the same problem but with System.Windows.Media.Imaging.CachedBitmap

HungryDoctor avatar Nov 16 '20 10:11 HungryDoctor