PC Review


Reply
Thread Tools Rate Thread

Deseralization problem...

 
 
=?Utf-8?B?YmFzdWxhc3o=?=
Guest
Posts: n/a
 
      5th Apr 2006
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???
 
Reply With Quote
 
 
 
 
Adam Benson
Guest
Posts: n/a
 
      11th Apr 2006
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???



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem after problem after problem - winXP wont start! =?Utf-8?B?TWF2aXJpY2s=?= Windows XP Help 2 23rd Apr 2006 03:55 PM
Object Deseralization issue =?Utf-8?B?QXJubw==?= Microsoft Dot NET 0 13th Oct 2004 03:01 PM
hibernation problem! problem!, Power Option problem! Farzad Hayati Microsoft Windows 2000 Hardware 2 5th Feb 2004 11:22 PM
hibernation problem! problem!, Power Option problem! Farzad Hayati Microsoft Windows 2000 Advanced Server 2 5th Feb 2004 11:22 PM
Outlook 2002 connector: problem connecting with Domino server because of NAMELookup2 problem Jean-Paul Smeets Microsoft Outlook 2 26th Sep 2003 11:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:44 PM.