a serialization problem
-
hi all, am developing an excel com addin using c#. In my addin, I am supposed to generate few buttons on the excel sheet's cells and perform their respective events on clicking. Every thing is working fine. Every button is named 'search' and is associated with its appropriate event handler(searchButton_Click). The button and its event handler constitute an object(of 'result' class). Now I tried to serialize the class Result so that I can save all the currently exisitng 'Result' objects, on the active sheet, to a file such that if I save this excel sheet and re open the sheet, I should be able to get back the controls(de serialize) of all the buttons present on the saved sheet. How ever in the serialization step, I am getting an exception that says: [System.Runtime.Serialization.SerializationException] = {"Type 'System.__ComObject' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."} Could anyone here please help me identify the exact problem here and am I missing anything? I did mark the class 'result' as 'Serializable'. In my 'result' class I have the code to generate a button on the sheet's active cell and that button's event handler. The buttons am generating on the excel sheet's cells are 'MSForms.CommandButton' types. Many thanks in advance!
-
hi all, am developing an excel com addin using c#. In my addin, I am supposed to generate few buttons on the excel sheet's cells and perform their respective events on clicking. Every thing is working fine. Every button is named 'search' and is associated with its appropriate event handler(searchButton_Click). The button and its event handler constitute an object(of 'result' class). Now I tried to serialize the class Result so that I can save all the currently exisitng 'Result' objects, on the active sheet, to a file such that if I save this excel sheet and re open the sheet, I should be able to get back the controls(de serialize) of all the buttons present on the saved sheet. How ever in the serialization step, I am getting an exception that says: [System.Runtime.Serialization.SerializationException] = {"Type 'System.__ComObject' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."} Could anyone here please help me identify the exact problem here and am I missing anything? I did mark the class 'result' as 'Serializable'. In my 'result' class I have the code to generate a button on the sheet's active cell and that button's event handler. The buttons am generating on the excel sheet's cells are 'MSForms.CommandButton' types. Many thanks in advance!
Did ya Google it? I just did and found a crap ton of results!
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
Did ya Google it? I just did and found a crap ton of results!
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
Hey, i did google but still not able to understand why am I not able to do it. Also, I have a doubt, if am doing some thing like this(code below) in a normal project(not an excel addin),this is 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 ), }; //SERIALIZING PART Stream s = File.Open("c:\\New Folder\\emp.txt", FileMode.Create,FileAccess.ReadWrite); BinaryFormatter b = new BinaryFormatter(); b.Serialize(s, e); s.Close(); //DESERIALIZING PART s = File.Open("c:\\New Folder\\emp.txt", FileMode.Open, FileAccess.ReadWrite); emp[] ee = (emp[])b.Deserialize(s); foreach (emp ez in ee) MessageBox.Show(ez.ToString()); s.Close(); But, the same is not working when am introducing this piece of code in my excel-addin project. What could be the reason for this behavour?! Thanks.