View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NA_AB[_2_] NA_AB[_2_] is offline
external usenet poster
 
Posts: 57
Default a serialization problem

Hi, in my excel com addin, am creating instances of buttons and their event
listeners on the excel sheet. Now in order to persist their operations even
after the instance of execution, am saving the sheet and trying to serialize
the list of 'ResultUi' objects that are maintained in an ArrayList(Arr_List).

here's the code am following:

Stream s = File.Open("c:\\New Folder\\empp.txt",
FileMode.Create, FileAccess.ReadWrite);
BinaryFormatter b = new BinaryFormatter();
ResultUi[] rj = new ResultUi[Arr_list.Count];
for (int i = 0; i < Arr_list.Count; i++)
{
rj[i] = (ResultUi)A[i];
b.Serialize(s, rj[i]);
}
s.Close();

This is giving me an exception! that says

'[System.Runtime.Serialization.SerializationExceptio n] = {"Type
'System.__ComObject' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' is not marked as serializable."}

I did mark the 'ResultUi' class [Serializable] but still why am I getting
this exception? Am I missing some thing?

A similar code, I came across on the net, is very much working fine:


emp[] e = {
new emp(1,"Mark",5000),
new emp(2,"Mich",6000),
new emp ( 3, "Amol", 4460 ),
new emp ( 4, "Anil", 9456 ),
new emp ( 5, "Srikanth", 9500 ),
};


Stream s = File.Open("c:\\New Folder\\emp.txt", FileMode.Create,
FileAccess.ReadWrite);
BinaryFormatter b = new BinaryFormatter();
b.Serialize(s, e);
s.Close();

any help in this regard is highly thankful.

Thanks in advance.

Regards,
na_ab