Saturday, March 24, 2012

Serializing between two projects

Hello All:

Say I have a solution with two projects (Project1 and Project2) and each
project contains a class (Project1 contains Class1 and Project2 contains
Class2).

The projects don't reference each other. Here's my question: can I
serialize Class1 and use the serialized XML in Class2? How would Class2
de-serialize the XML to retrieve the Class1's properties? I don't see how I
can do this since Project2 doesn't even know about Class1.

The example in MSDN (the Purchase Order Example) shows how to do this but
with classes in the same project. I want to do it with classes in different
projects.

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA AutomationSo long as both classes have the same name and the same public
interface, sure. It should deserialize just fine.

What happened when you tried?

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

--
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/
Jason,

Thanks for writing.

Class1 and Class2 are not the same class. Class2 uses Class1's properties.
For example, Class2 could have a method call where is needs some information
stored in Class1, i.e.

Sub Method2(TextValue as String, SomeClass1Value as Class1.Property1)

'Do something using the Class1's Property1...

End Sub

I need to pass the information contained in Class1 in Project1 to a method
in Class2 in Project2. I can't allow Project2 to reference Project1.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

"Jason Kester" wrote:

> So long as both classes have the same name and the same public
> interface, sure. It should deserialize just fine.
> What happened when you tried?
> Jason Kester
> Expat Software Consulting Services
> http://www.expatsoftware.com/
> --
> Get your own Travel Blog, with itinerary maps and photos!
> http://www.blogabond.com/
>
write your own serializer.

-- bruce (sqlwork.com)

"Joe" <joeherro@.donotspam.yahoo.com> wrote in message
news:DC2EFF4E-2F7E-4689-9223-D0A7B2AF3143@.microsoft.com...
> Hello All:
> Say I have a solution with two projects (Project1 and Project2) and each
> project contains a class (Project1 contains Class1 and Project2 contains
> Class2).
> The projects don't reference each other. Here's my question: can I
> serialize Class1 and use the serialized XML in Class2? How would Class2
> de-serialize the XML to retrieve the Class1's properties? I don't see how
> I
> can do this since Project2 doesn't even know about Class1.
> The example in MSDN (the Purchase Order Example) shows how to do this but
> with classes in the same project. I want to do it with classes in
> different
> projects.
> TIA,
> --
> Joe
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
How. I've never done this.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

"Bruce Barker" wrote:

> write your own serializer.
> -- bruce (sqlwork.com)
>
> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> news:DC2EFF4E-2F7E-4689-9223-D0A7B2AF3143@.microsoft.com...
> > Hello All:
> > Say I have a solution with two projects (Project1 and Project2) and each
> > project contains a class (Project1 contains Class1 and Project2 contains
> > Class2).
> > The projects don't reference each other. Here's my question: can I
> > serialize Class1 and use the serialized XML in Class2? How would Class2
> > de-serialize the XML to retrieve the Class1's properties? I don't see how
> > I
> > can do this since Project2 doesn't even know about Class1.
> > The example in MSDN (the Purchase Order Example) shows how to do this but
> > with classes in the same project. I want to do it with classes in
> > different
> > projects.
> > TIA,
> > --
> > Joe
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
Take a look at the sample I posted in reply to the other thread you started.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

"Joe" <joeherro@.donotspam.yahoo.com> wrote in message
news:C2005721-C6D0-4A96-AD10-25E8F75D7DF0@.microsoft.com...
> How. I've never done this.
> --
> Joe
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
> "Bruce Barker" wrote:
>> write your own serializer.
>>
>> -- bruce (sqlwork.com)
>>
>>
>> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
>> news:DC2EFF4E-2F7E-4689-9223-D0A7B2AF3143@.microsoft.com...
>> > Hello All:
>>> > Say I have a solution with two projects (Project1 and Project2) and
>> > each
>> > project contains a class (Project1 contains Class1 and Project2
>> > contains
>> > Class2).
>>> > The projects don't reference each other. Here's my question: can I
>> > serialize Class1 and use the serialized XML in Class2? How would
>> > Class2
>> > de-serialize the XML to retrieve the Class1's properties? I don't see
>> > how
>> > I
>> > can do this since Project2 doesn't even know about Class1.
>>> > The example in MSDN (the Purchase Order Example) shows how to do this
>> > but
>> > with classes in the same project. I want to do it with classes in
>> > different
>> > projects.
>>> > TIA,
>> > --
>> > Joe
>>> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>>
>>
>
Kevin,

Thanks. How would you handle this: DailyReport serializes its data to a
file (or memory stream or whatever). Now, another class (let's call this
class MonthlyReport) - in a different project - wants to de-serialize
DailyReport's data so that it can use it. Assume that MonthlyReport does not
have the same methods, properties, events, etc as DailyReport. How would
you create the XmlSerializer in the Deserializer method in MonthlyReport? Is
this even possible since it has different properties, methods, etc than
DailyReport?

I know how to do this when the class that performs the serialization and
de-serialization is the same class; I'm wondering if it can be done when the
class that serializes is different from the class that de-serializes.

Thanks for all of your help.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

"Kevin Spencer" wrote:

> Take a look at the sample I posted in reply to the other thread you started.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> Complex things are made up of
> Lots of simple things.
> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> news:C2005721-C6D0-4A96-AD10-25E8F75D7DF0@.microsoft.com...
> > How. I've never done this.
> > --
> > Joe
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > "Bruce Barker" wrote:
> >> write your own serializer.
> >>
> >> -- bruce (sqlwork.com)
> >>
> >>
> >> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> >> news:DC2EFF4E-2F7E-4689-9223-D0A7B2AF3143@.microsoft.com...
> >> > Hello All:
> >> >> > Say I have a solution with two projects (Project1 and Project2) and
> >> > each
> >> > project contains a class (Project1 contains Class1 and Project2
> >> > contains
> >> > Class2).
> >> >> > The projects don't reference each other. Here's my question: can I
> >> > serialize Class1 and use the serialized XML in Class2? How would
> >> > Class2
> >> > de-serialize the XML to retrieve the Class1's properties? I don't see
> >> > how
> >> > I
> >> > can do this since Project2 doesn't even know about Class1.
> >> >> > The example in MSDN (the Purchase Order Example) shows how to do this
> >> > but
> >> > with classes in the same project. I want to do it with classes in
> >> > different
> >> > projects.
> >> >> > TIA,
> >> > --
> >> > Joe
> >> >> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >>
> >>
> >>
>
Hi Joe,

I can see where this is heading. Read the following articles and references:

http://msdn.microsoft.com/library/d...rialization.asp
http://msdn.microsoft.com/library/d...lasstopic .asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

"Joe" <joeherro@.donotspam.yahoo.com> wrote in message
news:8D2595AF-7D74-4575-8179-BF00494AB219@.microsoft.com...
> Kevin,
> Thanks. How would you handle this: DailyReport serializes its data to a
> file (or memory stream or whatever). Now, another class (let's call this
> class MonthlyReport) - in a different project - wants to de-serialize
> DailyReport's data so that it can use it. Assume that MonthlyReport does
> not
> have the same methods, properties, events, etc as DailyReport. How would
> you create the XmlSerializer in the Deserializer method in MonthlyReport?
> Is
> this even possible since it has different properties, methods, etc than
> DailyReport?
> I know how to do this when the class that performs the serialization and
> de-serialization is the same class; I'm wondering if it can be done when
> the
> class that serializes is different from the class that de-serializes.
> Thanks for all of your help.
> --
> Joe
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
> "Kevin Spencer" wrote:
>> Take a look at the sample I posted in reply to the other thread you
>> started.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> ..Net Developer
>> Complex things are made up of
>> Lots of simple things.
>>
>> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
>> news:C2005721-C6D0-4A96-AD10-25E8F75D7DF0@.microsoft.com...
>> > How. I've never done this.
>> > --
>> > Joe
>>> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>>>> > "Bruce Barker" wrote:
>>> >> write your own serializer.
>> >>
>> >> -- bruce (sqlwork.com)
>> >>
>> >>
>> >> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
>> >> news:DC2EFF4E-2F7E-4689-9223-D0A7B2AF3143@.microsoft.com...
>> >> > Hello All:
>> >>> >> > Say I have a solution with two projects (Project1 and Project2) and
>> >> > each
>> >> > project contains a class (Project1 contains Class1 and Project2
>> >> > contains
>> >> > Class2).
>> >>> >> > The projects don't reference each other. Here's my question: can I
>> >> > serialize Class1 and use the serialized XML in Class2? How would
>> >> > Class2
>> >> > de-serialize the XML to retrieve the Class1's properties? I don't
>> >> > see
>> >> > how
>> >> > I
>> >> > can do this since Project2 doesn't even know about Class1.
>> >>> >> > The example in MSDN (the Purchase Order Example) shows how to do
>> >> > this
>> >> > but
>> >> > with classes in the same project. I want to do it with classes in
>> >> > different
>> >> > projects.
>> >>> >> > TIA,
>> >> > --
>> >> > Joe
>> >>> >> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>> >>
>> >>
>> >>
>>
>>
>
Hi Kevin,

Thanks. I've already read these. The examples that they give are for
classes that all exist in the same project. I am asking about serializing a
class in one project and de-serializing it in another project.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

"Kevin Spencer" wrote:

> Hi Joe,
> I can see where this is heading. Read the following articles and references:
> http://msdn.microsoft.com/library/d...rialization.asp
> http://msdn.microsoft.com/library/d...lasstopic .asp
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> Complex things are made up of
> Lots of simple things.
> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> news:8D2595AF-7D74-4575-8179-BF00494AB219@.microsoft.com...
> > Kevin,
> > Thanks. How would you handle this: DailyReport serializes its data to a
> > file (or memory stream or whatever). Now, another class (let's call this
> > class MonthlyReport) - in a different project - wants to de-serialize
> > DailyReport's data so that it can use it. Assume that MonthlyReport does
> > not
> > have the same methods, properties, events, etc as DailyReport. How would
> > you create the XmlSerializer in the Deserializer method in MonthlyReport?
> > Is
> > this even possible since it has different properties, methods, etc than
> > DailyReport?
> > I know how to do this when the class that performs the serialization and
> > de-serialization is the same class; I'm wondering if it can be done when
> > the
> > class that serializes is different from the class that de-serializes.
> > Thanks for all of your help.
> > --
> > Joe
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > "Kevin Spencer" wrote:
> >> Take a look at the sample I posted in reply to the other thread you
> >> started.
> >>
> >> --
> >> HTH,
> >>
> >> Kevin Spencer
> >> Microsoft MVP
> >> ..Net Developer
> >> Complex things are made up of
> >> Lots of simple things.
> >>
> >> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> >> news:C2005721-C6D0-4A96-AD10-25E8F75D7DF0@.microsoft.com...
> >> > How. I've never done this.
> >> > --
> >> > Joe
> >> >> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >> >> >> > "Bruce Barker" wrote:
> >> >> >> write your own serializer.
> >> >>
> >> >> -- bruce (sqlwork.com)
> >> >>
> >> >>
> >> >> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> >> >> news:DC2EFF4E-2F7E-4689-9223-D0A7B2AF3143@.microsoft.com...
> >> >> > Hello All:
> >> >> >> >> > Say I have a solution with two projects (Project1 and Project2) and
> >> >> > each
> >> >> > project contains a class (Project1 contains Class1 and Project2
> >> >> > contains
> >> >> > Class2).
> >> >> >> >> > The projects don't reference each other. Here's my question: can I
> >> >> > serialize Class1 and use the serialized XML in Class2? How would
> >> >> > Class2
> >> >> > de-serialize the XML to retrieve the Class1's properties? I don't
> >> >> > see
> >> >> > how
> >> >> > I
> >> >> > can do this since Project2 doesn't even know about Class1.
> >> >> >> >> > The example in MSDN (the Purchase Order Example) shows how to do
> >> >> > this
> >> >> > but
> >> >> > with classes in the same project. I want to do it with classes in
> >> >> > different
> >> >> > projects.
> >> >> >> >> > TIA,
> >> >> > --
> >> >> > Joe
> >> >> >> >> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>

0 comments:

Post a Comment