Click here to Skip to main content
0 members
Rate this:
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
    public interface IService1
        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( )

            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 ???
Updated 4-Nov-12 18:57pm

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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

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