Serializing between two projects

G

Guest

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,
 
J

Jason Kester

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/
 
G

Guest

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.
 
G

Guest

How. I've never done this.
--
Joe

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


Bruce Barker said:
write your own serializer.

-- bruce (sqlwork.com)
 
K

Kevin Spencer

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 said:
How. I've never done this.
 
G

Guest

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top