I recently made my own custom formatter, it takes a runtime object and writes down an object graph of it in a string format then takes that string and converts it back to a runtime object.
Example: [CustomFormatter.Btype, CustomFormatter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null==[a==5][b==0]]
after messing around with primitive objects (int, bool, float...) I tried to serialize a Bitmap object into string using the ISerializable interface and it worked well but when I try to reconstruct the object back I'm getting an error System.MissingMethodException: Constructor on type 'System.Drawing.Bitmap' not found.
If bitmap doesn't have a constructor which takes SerializationInfo and StreamingContext as parameters how else can an object which inherits the ISerializable interface be constructed?
This part is is the main issue but I can include the whole code:
private static object SeriObjConstructor(Type objType, ref string dataInfo, ref int location)
{
SerializationInfo info = new SerializationInfo(objType, new FormatterConverter());
StreamingContext context = new StreamingContext(StreamingContextStates.All);
location += serializerEntry.Length;
while (!CheckHitOperator(dataInfo, serializerExit, ref location))
{
KeyValuePair<string, Type> serializedObj = GetSerialiedName(ref dataInfo, ref location); //<name, type>
info.AddValue(serializedObj.Key, Construction(serializedObj.Value, ref dataInfo, ref location));
}
location += serializerExit.Length;
location += endClass.Length;
var instance = Activator.CreateInstance(objType, info, context); //THROWS AN ERROR
return instance;
}