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

  • Thread starter Thread starter Rade
  • Start date Start date
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;
}
 
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
 
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.
 
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.
 
Back
Top