Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. a serialization problem

a serialization problem

Scheduled Pinned Locked Moved C#
helpcsharpcomjsonquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abhiram_nayan
    wrote on last edited by
    #1

    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!

    E 1 Reply Last reply
    0
    • A abhiram_nayan

      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!

      E Offline
      E Offline
      Expert Coming
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • E Expert Coming

        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

        A Offline
        A Offline
        abhiram_nayan
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups