[Mono-dev] when using “fileStream”though WCF in monodevelop

LMD 821624832 at qq.com
Mon Sep 2 10:11:34 UTC 2013


I use WCF in Unity though monodevelop.When I using "FileStream",it goes
wrong.
The service code is like this: 
   
 public Stream GetFile(String filepath)       
 {
   Stream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read);         
   return stream;    
 }

The client code is like this:
	void Start () {	
			
		Iservice1Client client = new Iservice1Client(new BasicHttpBinding(),		
				new EndpointAddress("http://localhost:8456/Service1.svc"));
		Stream fileStream = client.GetFile(filepath);
              	
		client.Close();
	}

When using GetFile() method,the mono client dies with the following
exception: 

Unhandled Exception: 
System.Runtime.Serialization.SerializationException: Deserializing 
type 'System.IO.Stream'. Expecting state 'EndElement'. Encountered 
state 'Text' with name '' with namespace ''. 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize 
(System.Type type, System.Xml.XmlReader reader) [0x00000] 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize 
(System.Xml.XmlReader reader, System.Type type, 
System.Runtime.Serialization.KnownTypeCollection knownTypes, 
IDataContractSurrogate surrogate, System.String name, System.String 
Namespace, Boolean verifyObjectName) [0x00000] 
  at System.Runtime.Serialization.DataContractSerializer.ReadObject 
(System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) 
[0x00000] 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObject 
(System.Xml.XmlDictionaryReader reader) [0x00000] 
  at 
System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts 
(System.ServiceModel.Description.MessageDescription md, 
System.ServiceModel.Channels.Message message) [0x00000] 
  at 
System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply 
(System.ServiceModel.Channels.Message message, System.Object[] 
parameters) [0x00000] 
  at System.ServiceModel.ClientRuntimeChannel.Request 
(System.ServiceModel.Description.OperationDescription od, 
System.Object[] parameters) [0x00000] 
  at System.ServiceModel.ClientRuntimeChannel.Process 
(System.Reflection.MethodBase method, System.String operationName, 
System.Object[] parameters) [0x00000] 
  at __clientproxy_Contract.method (TimeSpan ) [0x00000] 
  at WCFTestClient.Program.Main (System.String[] args) [0x00000] 

Can anyone help me?



--
View this message in context: http://mono.1490590.n4.nabble.com/when-using-fileStream-though-WCF-in-monodevelop-tp4660737.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list