Can a Object from BinaryFormatter be changed to SoapFormatter? It's Urgent!!!! Help me.

R

Rade

I have an object, from .net remoting, using binaryformatter, I have a
way to stored it to a file. and then, I want to deserialize it and
serialize it again to Soap format. can this be done?

till now, I can deserialize it from binformatter to an object, but I
can't serialize to Soap(xml) format, it throws error.
I am using the function below, if the object class(stored in a file) is
created in the same project, it works fine. but not the object from
other programs, even if I have referenced the DLL files.

Anyone help me? it's really urgent, I am blocked here for a long time.


I hope you understand what I said, and give me a hand, thanks very
much.


public bool readBin2Soap(string fromFile, string toFile){

Stream stream = File.Open(fromFile, FileMode.Open);
sformatter = new SoapFormatter();
bformatter = new BinaryFormatter();

Object obj = (Object)bformatter.Deserialize(stream);

Stream stream2 = File.Open(toFile, FileMode.Create);

//till now, everything works fine, but not the
following step,
sformatter.Serialize(stream2, obj);//<--this one will throws error.

stream2.Close();

stream.Close();
return true;
}
 
J

John B

Rade said:
I have an object, from .net remoting, using binaryformatter, I have a
way to stored it to a file. and then, I want to deserialize it and
serialize it again to Soap format. can this be done?

till now, I can deserialize it from binformatter to an object, but I
can't serialize to Soap(xml) format, it throws error.
I am using the function below, if the object class(stored in a file) is
created in the same project, it works fine. but not the object from
other programs, even if I have referenced the DLL files.

Anyone help me? it's really urgent, I am blocked here for a long time.


I hope you understand what I said, and give me a hand, thanks very
much.


public bool readBin2Soap(string fromFile, string toFile){

Stream stream = File.Open(fromFile, FileMode.Open);
sformatter = new SoapFormatter();
bformatter = new BinaryFormatter();

Object obj = (Object)bformatter.Deserialize(stream);

Stream stream2 = File.Open(toFile, FileMode.Create);

//till now, everything works fine, but not the
following step,
sformatter.Serialize(stream2, obj);//<--this one will throws error.

stream2.Close();

stream.Close();
return true;
}
What exception does it throw?
JB
 
R

Rade

Thanks for your reply.
For my Environment is in Chinese, I don't know the exact exception,
something like
Methods not supported. in the process of serializing in soapFormatter.
 
R

Rade

I got it.
It's because the object I caught is not the really object, for its from
..net remoting, the actural object is MethodCall, from
System.Runtime.Remoting.Messaging.MethodCall.

the exception is because object MethodCall can't use soap formatter.

So now, what I need is change methodcall to a plain text.
 

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