We help IT Professionals succeed at work.

Tyring to Serialize/Deserialize Office Class Objects

DarklingG asked
Last Modified: 2011-09-20
I'm currently working an Reporting System to produce large amounts of Powerpoint Presentations from set data sources. This is all fine.

 But, my users don't always want to use just the standard set of Powerpoint Slides, they want to have custom ones depending on the service they provide.

 What I need to do is easily serialize individual Slides into Binary or SOAP (currently using Binary) and store them in a database so I can retrieve them.

 The below is working fine for images and custom classes, etc., but won't work with the Office Objects.

 Can someone help as to why? And hopefully provide an answer?

public class GeneralObjectSerialization<T>
        BinaryFormatter newBin;
        MemoryStream newStream;
        public byte[] SerializeObjectAndReturnByteArray(T newObject)
            byte[] newByteArray;
            newBin = new BinaryFormatter();
            newStream = new MemoryStream();
            newBin.Serialize(newStream, newObject);
            newByteArray = newStream.GetBuffer();
            return newByteArray;
        public T Deserialize(byte[] arrayStream)
            T newObject;
            newBin = new BinaryFormatter();
            newStream = new MemoryStream();
            newStream.Seek(0, 0);
            newObject = (T)newBin.Deserialize(newStream);
            return newObject;

Open in new window

Watch Question

When you try do you get a serialization exception explaining that the objects i.e. the slide objects are not serializable?




 It just doesn't want to serialize the SlideClass class.
This one is on us!
(Get your first solution completely free - no credit card required)



 I thought that would be the route I'd need to take.

 Shame, I thought I was missing something small that solve all the worries for me.

Can you post the fully qualified name of the Slide Object pls.


Not sure what you're after here, but I have:

  GeneralObjectSerialization newSer = new GeneralObjectSerialization();
  SlideClass newSlide;
  newSlide = newPres.Slides[1];    // 1 for example

  byte[] newData = SerializeObjectAndReturnByteArray(newSlide);

 I haven't had time to create my personal abstract slide class yet.



FYI. I have elected to split out the Slides I need into individual presentations and then store the entire file via a FileStream serialization.

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.