473,385 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

serializing a COM object

Is it possible to serialize a COM class for which you don't have the
source code? Obviously it won't work without the [Serializable]
attribute, which I can't add, and implementing ISerializable on a
derived class won't help because I don't have access to the private
fields that I would need to write to a file for the serialization to
be successful.

Is there a way to write the block of memory from a pointer? I could
use Marshal.StructureToPtr() to get a pointer to the object and
Marshal.SizeOf() to determine how much memory it takes up, and write
all of that to a binary file.

Jul 23 '07 #1
2 2140
Craig,
It sounds like you are asking to serialize an unmanaged object, which is
probably asking a bit too much from the managed CLR. What exactly is it that
you need to do here? There may be a "managed way".
Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"cr**********@gmail.com" wrote:
Is it possible to serialize a COM class for which you don't have the
source code? Obviously it won't work without the [Serializable]
attribute, which I can't add, and implementing ISerializable on a
derived class won't help because I don't have access to the private
fields that I would need to write to a file for the serialization to
be successful.

Is there a way to write the block of memory from a pointer? I could
use Marshal.StructureToPtr() to get a pointer to the object and
Marshal.SizeOf() to determine how much memory it takes up, and write
all of that to a binary file.

Jul 23 '07 #2
The only way to really do this is to look for one of the COM IPersist
interfaces, and then serialize to whatever format it supports (there is
IPersistMoniker, IPersistFile, IPersistStorage, IPersistMemory, etc, etc).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yohohhoandabottleofrum.comwrote
in message news:D6**********************************@microsof t.com...
Craig,
It sounds like you are asking to serialize an unmanaged object, which is
probably asking a bit too much from the managed CLR. What exactly is it
that
you need to do here? There may be a "managed way".
Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"cr**********@gmail.com" wrote:
>Is it possible to serialize a COM class for which you don't have the
source code? Obviously it won't work without the [Serializable]
attribute, which I can't add, and implementing ISerializable on a
derived class won't help because I don't have access to the private
fields that I would need to write to a file for the serialization to
be successful.

Is there a way to write the block of memory from a pointer? I could
use Marshal.StructureToPtr() to get a pointer to the object and
Marshal.SizeOf() to determine how much memory it takes up, and write
all of that to a binary file.

Oct 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
6
by: Rein Petersen | last post by:
Hi Folks! Here's a strange behaviour: Without a properties SET accessor (see code below), the property will not serialize. public class myObject {
1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
4
by: Jason Shohet | last post by:
We are thinking of serializing an object & passing it toseveral functions on web service. This will happen about 35 times as the page loads. The class has about 20 attributes. We're not sure...
3
by: axr | last post by:
Having trouble with Serilization of objects that contain members which are of type Interface eg public class SomeClass { ISomeInterface1 itf1; ClassType1 ct1; ISomeInterface2 itf2;
4
by: mookid8000 | last post by:
Good day group! I have created a nice filtering plugin system, where all filters derive from a Filter class, and they pass a PictureData object between them. I have a problem though. I am able...
2
by: Charles Law | last post by:
I have a complex object that I am serializing, and I would like to omit elements that have a default value. For example, if I have a class as follows Public Class Test Private m_Name As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.