On Jun 8, 7:33 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
In this case, I would look to see if the object implements the
IPersistMemory interface. This is a COM interface (which I mention because
this is an Excel workbook, which is a COM object, ultimately) which allows
the state of the object to be persisted to unmanaged memory. You can then
marshal that to a managed byte array, or do whatever you wish with it.
You can also look for the IPersistFile interface, or the IPersistStream
interface, and see if the workbook supports those. Those will persist to a
file, and a stream (a COM IStream implementation).
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
messagenews:Oh**************@TK2MSFTNGP02.phx.gbl. ..
Hi,
"Aneesh Pulukkul[MCSD.Net]" <anees...@gmail.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...
How to convert a "Non Serializable" object to byte array. The object
is a dynamically created Excel workbook. As per my understanding an
object can be written and read from a stream Only if it's serialized.
Any ideas?
If the object is not serializable then you will have to do it yourself. In
your particular case I do not see how you can do so (unless you have the
source code of the class you want to serialize).
Refering to your other question, an object can be readed/written to a
stream (or a file) if they provide methods for that.- Hide quoted text -
- Show quoted text -
Thank you guys for the info.
Regarding the Ipersismemory interface, I really don't know about the
interface. The definiton for workbook class is seen in the metadata:
[ClassInterface(0)]
[Guid("00020819-0000-0000-C000-000000000046")]
[ComSourceInterfaces("Microsoft.Office.Interop.Exce l.WorkbookEvents")]
[TypeLibType(2)]
public class WorkbookClass : _Workbook, Workbook,
WorkbookEvents_Event
[CoClass(typeof(WorkbookClass))]
[Guid("000208DA-0000-0000-C000-000000000046")]
public interface Workbook : _Workbook, WorkbookEvents_Event
[Guid("000208DA-0000-0000-C000-000000000046")]
[TypeLibType(4160)]
public interface _Workbook