Serialization problem

E

Eric

Hi,

I was under the impression that with serialization I could transfer a block
of data from one application to another.
So I wrote a website where after the user had put in some data, it is put in
a structure and that structure is serialized into a file.

Then this file is emailed and the backend user reads it in an application
for processing.

If I try to read the file into the same kind of structure, I get an
exception error.
Apparently it needs the webpage that generated the file to open it???

This is putting me in a lot of trouble as the website is already in use.

Is there a way to read the data from the files without the assembly that
created it?

Please help me with this!!

rg,
Eric
 
C

Cor Ligthert[MVP]

Probably Yes,

Create in the receiving code, the same class description as in the sending
one, and use that to deserialize as the type.

Otherwise serialize to XML and send the scheme included.
 
P

Phill W.

I was under the impression that with serialization I could transfer a block
of data from one application to another.
Sometimes.

So I wrote a website where after the user had put in some data, it is put in
a structure and that structure is serialized into a file.
Then this file is emailed and the backend user reads it in an application
for processing.
If I try to read the file into the same kind of structure, I get an
exception error.

That will be because the Type that was created and serialised is
/different/ from the Type into which you're trying to deserialise it.

Even if you cut and paste the code from one project to the other, it
will [almost certainly] not work. A Type defined within one project is
/different/ from a Type defined in any other project, even if it looks
the identical to the named eye.

You need to extract this class into a common library (.dll) and
reference this library from both projects (and preferably with the
library in the Global Assembly Cache, if you can).

That's the /only/ reliable way I've got anything like this to work.

HTH,
Phill W.
 

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

Top