Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi good folks,
I am trying to open a file and read the data using Silverlight where the file/Stream is effectively opened via a WCF class that encapsulates a stream.
 
When I attempt to implement what is described above the Async event handier return parameter, e.Result returns a Byte[] rather than a Stream, why ?
 
Below is what I have implemented:
 
namespace SilverlightApplication1.Web
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        Stream GetAStream( );
    }
}
 
The implemented class:
 
public class Service1 : IService1
    {
        public Stream GetAStream( )
        {
            return new FileStream( @"C:\temp\hello.txt", FileMode.Open );
        }
    }
 

On the Silverlight client side when I add the WCF service reference I add the GetAStream call as shown below.
 
public partial class MainPage : UserControl
    {
        public MainPage( )
        {
            InitializeComponent();
 
            ServiceReference1.Service1Client sc = new ServiceReference1.Service1Client();
            sc.GetAStreamCompleted +=new EventHandler.ServiceReference1.GetAStreamCompletedEventArgs(sc_GetAStreamCompleted);
        }
 
        public void sc_GetAStreamCompleted (object sender, ServiceReference1.GetAStreamCompletedEventArgs e)
        {
 
           Byte[] bytes = e.Result;
// I was hoping the result would be something like Stream xyz = e.Result ???
}
           
Posted 4-Nov-12 19:29pm
Edited 4-Nov-12 19:57pm
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100