473,385 Members | 1,356 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 2139
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.