Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4560604
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:57:13+00:00 2026-05-21T17:57:13+00:00

I have a WCF service and Im looking to stream some files from server

  • 0

I have a WCF service and Im looking to stream some files from server to client.

I have had this working when I hard code the filename of the file to stream into the code.

I am trying to change the code so that the getStream method returns a Dictionary so I can return a collection of filenames and the stream associated with the filename and then process each stream at the client side.

I am getting the following exception on the client side when trying to call the getStream method:
An error occurred while receiving the HTTP response to http://localhost:8082/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

After researching this on the net it looks like this is a false exception so I turned on tracing and this is the exceptionn message fromt eh trace log:

There was an error while trying to serialize parameter http://tempuri.org/:GetStreamResult. The InnerException message was ‘Type ‘System.IO.FileStream’ with data contract name ‘FileStream:http://schemas.datacontract.org/2004/07/System.IO’ is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.’. Please see InnerException for more details.

Here is the Server side code:

public Dictionary<String, Stream> GetStream()
    {
        Dictionary<String, Stream> retDic = new Dictionary<string, Stream>();          

        string[] fileEntries = Directory.GetFiles(@"C:\Users\Ash\Desktop\FrontendPluginsServer");
        foreach (string fileName in fileEntries)
        {
             //do something with fileName
            retDic.Add(fileName, File.OpenRead(fileName));
        }
        //return File.OpenRead(@"C:\Users\Ash\Desktop\FrontendPluginsServer\OptekImporterFrontend.dll");

        return retDic;
    }

Here is the client side code:

ModuleDownloader.ModuleDownloaderClient moo = new ModuleDownloader.ModuleDownloaderClient();
        Dictionary<String, Stream> dic = moo.GetStream();

        foreach (String key in dic.Keys)
        {
            using (Stream file = File.OpenWrite(@"C:\Users\Ash\Desktop\FrontEndPluginsClient\" + key)) { CopyStream(dic[key], file); }
        }

Please let me know if you need anymore information.

Kind Regards

Ash

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:57:14+00:00Added an answer on May 21, 2026 at 5:57 pm

    There is no way you can do this.

    • FileStream is not serialisable. The reason it tries to serialise it is that it does not follow WCF streaming conventions.
    • WCF restrictions on streaming defines that you have to have a single Stream in the method signature and nothing else if you wanna use WCF Streaming.

    At any time, you can only send a single stream.

    Read more here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into refactoring some old code into a new WCF service,
Looking for some guidance on a WCF service I’m prototyping. I have a WCF
I will have a client application using a proxy to a WCF Service. This
I have a legacy service I'm looking to update to WCF and one of
I have a WCF service that I have to reference from a .net 2.0
I have a per-call WCF service that serves a number of clients. I'm looking
I have a WCF client and service using HTTPS over the wsHttpBinding. One common
I am trying to debug a WCF service. This client has been able to
I have a working WCF Data Service built on a Linq2Sql data provider. Things
I have a plugin that exposes a wcf service. if I test this service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.