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 8881107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:16:45+00:00 2026-06-14T20:16:45+00:00

I need to return a big byte array from a WCF server. The problem

  • 0

I need to return a big byte array from a WCF server.

The problem is – in order to return such an array – I need to create one – and when creating such an array – it automatically goes to the Large Object Heap – meaning that when the service is stressed – I’m getting a real problem in memory usage and management.

I thought about using unmanaged memory to avoid using large managed byte arrays – but still – how can I return such an array from a WCF service?

Is there any way of returning a “Stream” of bytes from a WCF service that does not include actually creating a managed byte array? I know that WCF itself uses a BufferManager – so if it just reads my unmanaged memory and uses its buffer management to store it before sending – I hopefully won’t have a problem.

  • 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-06-14T20:16:46+00:00Added an answer on June 14, 2026 at 8:16 pm

    You can use WCF’s Streaming Mode. From that page:

    1. To stream data, the OperationContract for the service must satisfy two requirements:

      a. The parameter that holds the data to be streamed must be the only
      parameter in the method. For example, if the input message is the one
      to be streamed, the operation must have exactly one input parameter.
      Similarly, if the output message is to be streamed, the operation must
      have either exactly one output parameter or a return value.

      b. At least one of the types of the parameter and return value must be
      either Stream, Message, or IXmlSerializable.

    2. Streaming must be enabled on the binding. You set a TransferMode property, which can take one of the following values:

      a. Buffered,

      b. Streamed, which enables streaming communication in both directions.

      c. StreamedRequest, which enables streaming the request only.

      d. StreamedResponse, which enables streaming the response only.

    There are some decent examples on that page as well, including how to write back a custom stream (it’s toward the bottom).

    For more background info on encoding, streaming and sessions, and some security considerations when using streaming, see this MSDN page.

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

Sidebar

Related Questions

I need to return server time from a webservice. I've got the following code:
I need to write an integer to a byte array such that leading zeros
I need to return an a generic list in the correct order for my
I need to return a full directory name from inside a specified directory that
I need to return multiple values from a ColdFusion function in an ajax callback
I need to return an array in php and use it in javascript. When
I have need to return multiple results from a subquery and have been unable
In a WCF Service, I need to create a variable which should be accessible
So Ive got a pretty big array of data and need to sort them
I need to return a rather big file (11MB) to the user. For certain

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.