Thanks Samuel for all of your help.
I am trying to use binaryformatter. I have no trouble saving (serializing),
but when I go to deserialize I always get errors. It appears that I cannot
set a breakpoint or anything to discover where the problem is.
I am serializing by implementing ISerializable: The GetObjectData method &
the custom Constructor.
The last problem I got was an exception--TargetInvocationException class to
be exact.
My object model has things like the following to deal with:
MDIForm (which has a bunch of frmA's)
frmA
which has a Workspace object. This object has some members and then some
other objects.
for the sake of this newsgroup let me give an example scenario and see what
I should do.
Workspace has a reference to the form that "owns" it (this is not
serializable of course).
So imagine
class workspace
private A as single
private B as single
private ParentForm as frmA
private objSomething as Something
end class
class Something
'class something has a reference to the parentworkspace to which it
belongs
private ParentWorkSpace as workspace
end class
my thought was, in GetDataObject for workspace object to just do the
following:
info.addvalue("A",A)
info.addvalue("B",B)
info.addvalue("objSomething",Something)
and then in the specialized contstructor for deserializing
A=info.getsingle("A")
B=info.getsingle("B")
objSomething=ctype(info.getvalue("objSomething",gettype(something)),somethin
g)
'then at this point, maybe call a method on objSomething to set the
parent workspace object
'reference to this object
objSomething.SetParentWorkspace=me
I would do the same thing to the Workspace object itself after being
deserialized, it would set the ParentForm with a method.
Am I on the wrong track? Any ideas, from you or any other group member
about the exception.
Also any ideas on how to debug this stuff, since it seems to just happen and
not allow me to step into the call, which I assume just eventually calls the
constructor.
Thanks for all your help.
Shane
[quoted text, click to view] "Samuel R. Neff" <blinex@newsgroup.nospam> wrote in message
news:otq551h4a416lte26fm6235rjhqpo484go@4ax.com...
>
> Unfortunately there's a huge leap between XmlSerializer and custom
> serialization--quick and dirty vs totally do it yourself. There are
> lots issues that XmlSerializer doesn't address and for that reason a
> lot of people (most it seems) recommend doing it yourself.
>
> XmlSerializer does do a good job for what it's programmed to do, so if
> you can use it in your situation I'd suggest doing so--you can always
> switch to custom if you really need more functionality. We of course
> have the same concerns over versioning that you do and have an
> architecture to get around it (well, planned architecture) by using a
> bookmarked XML reader combined with XSLT.
>
> Basically, we'll read the XML up to a Version attribute on the root
> element. If that matches the current, then reset the reader to the
> beginning and process as normal.
>
> If the version is old, then reset the reader and perform a
> transformation on it to get the new format (requires writing XSLT,
> which some consider more complicated then writing a custom
> serializer).
>
> If the version is newer, then cancel or take whatever action is
> appropriate in your application.
>
> Here's a bookmarked XML reader from MS:
>
>
http://msdn.microsoft.com/XML/BuildingXML/XMLinNETFramework/default.aspx?pull=/library/en-us/dnxmlnet/html/XmlBkMkRead.asp
>
> It has some issues of it's own--it won't even compile as distributed.
> But once they're fixed, it seems to work pretty well (fixes: invalid
> boolean check at end with bool != null, and a Debug.Assert that always
> gets triggered).
>
> HTH,
>
> Sam
>
>
> On Tue, 5 Apr 2005 14:41:12 -0500, "Shane Story"
> <shanesREMOVETHIS@dv-corp.com> wrote:
>
> >Thanks Samuel.
> >
> >Considering what else I have read on the subject, it seems that if you
> >serialize and object and later make any changes, that the things
serialized
> >before the change would not be readable. For this reason custom
> >serialization seems better. Would you agree?
> >
> >Thanks
> >
>
> B-Line is now hiring one Washington D.C. area VB.NET
> developer for WinForms + WebServices position.
> Seaking mid to senior level developer. For
> information or to apply e-mail resume to
> sam_blinex_com.