Usually a class that has manual serialisation (where you have a routine that
does the serialising for you - your GetObjectData method) needs a ctor that
looks something like this :
protected MyClass(SerializationInfo info, StreamingContext context)
{
myint64 = info.GetInt64("f1");
mybool = info.GetBoolean("b1");
}
You might try sticking a default ctor in, as well
i.e.
public MyClass()
Try this. HTH,
Adam.
"basulasz" <(E-Mail Removed)> wrote in message
news:9A879A0E-6487-47F9-BD7F-(E-Mail Removed)...
>I have a mail class which is extended from Outlook.MailItem like below to
> make it serializable
>
> [Serializable]
> public class myMail : ISerializable
> {
> Outlook.MailItem Mail;
> public myMail(Outlook.MailItem Mail)
> {
> this.Mail = Mail;
> }
>
> public Outlook.MailItem getMail()
> {
> return Mail;
> }
>
> void ISerializable.GetObjectData(SerializationInfo info,
> StreamingContext context)
> {
>
> }
> }
>
> I serialize the object which is created by it with the below function
>
> public byte[] getByteArrayWithObject(Outlook.MailItem o)
> {
> MemoryStream ms = new MemoryStream();
> BinaryFormatter bf1 = new BinaryFormatter();
> myMail myo = new myMail(o);
> bf1.Serialize(ms, myo);
> return ms.ToArray();
> }
>
> Then again I create a MailItem object with this code
>
> Outlook.MailItem mailItem =
> (Outlook.MailItem)this.CreateItem(Outlook.OlItemType.olMailItem);
>
> myMail myDeserializedMail = new myMail(mailItem);
>
> And then i want to deserialize the object which i get from db (in binary
> form) with the below code
>
> public object getObjectWithByteArray(byte[] theByteArray)
> {
> MemoryStream ms = new MemoryStream(theByteArray);
> BinaryFormatter bf1 = new BinaryFormatter();
> ms.Position = 0;
>
> return bf1.Deserialize(ms);
> }
>
> --> getObjectWithByteArray(blob);
>
> But at this moment i raises exception that
>
> "ex = {"The constructor to deserialize an object of type 'GetMail.myMail'
> was not found."}"
>
> What can i do???
|