On Apr 17, 8:36 am, Chris Dunaway <dunaw...@gmail.com> wrote:
> On Apr 16, 9:14 am, "Marc" <newmexicoguacam...@gmail.com> wrote:
>
> > Hi,
> > I am trying to serialize a data structure -- a list (of custom class)
> > -- in one application, then read it in with another application. My
> > serialize and deserialize subs are in a module that is shared between
> > the two applications, so they are using exactly the same code (this
> > module also contains the class, so I am certain the class code is the
> > same)
>
> What does this mean, exactly? Have you placed your serialization code
> in a class library and both applications reference that library? Or do
> both applications simply share the same code file? If they share the
> same code file, then that is likely your problem. Even if they have
> identical code, the classes are still considered different types and
> the second application will not be able to deserialize the file that
> is serialized by the first.
>
> <snip>
>
> > Try
> > GenericObject = MyFormatter.Deserialize(myFileStream)
> > AllOrders = CType(GenericObject, List(Of TEOrder))
> > Catch ex As Exception
> > Finally
> > myFileStream.Close()
> > End Try
> > End Function
>
> > No exception is ever raised. When I serialize, I can check the file
>
> As the other poster pointed out, you are catching and swallowing the
> exception.
>
>
>
> > BTW I would be interested in using the SOAPFormatter but I can't find
> > it in VB.NET. I read about it online but don't see it available.
> > What do I need to do to make that available to me? (I would much
> > prefer human-readable output when I serialize)
>
> The SoapFormatter is defined in the
> System.Runtime.Serialization.Formatters.Soap namespace which is
> contained, coincidentally, in
> System.Runtime.Serialization.Formatters.Soap.dll. Add a reference to
> that assembly and you can get at the SoapFormatter.
>
> Chris
Thanks Chris (and Schneider)
I decided to investigate the exceptions a little more and realized
that because I was simply using two copies of the same class files,
the namespaces were not shared and I could not share objects. Thus I
have created a class library which is used by both applications now,
and I am gleefully sharing objects.
(Then I checked the newgroup and found Chris's reply, which would have
saved me a lot of time if it had come a few hours earlier!)
Also thanks for the SoapFormatter information.
Regards,
Marc
|