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

  • SEARCH
  • Home
  • 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 7745677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:04:53+00:00 2026-06-01T10:04:53+00:00

I wrote a WCF service that reads data from my SQL Server database. It

  • 0

I wrote a WCF service that reads data from my SQL Server database. It works fine when a call a method that returns all strings, but if I call a method that returns an int it crashes with some error about a timeout and too much data, which doesn’t make sense to me…

Here is my web service code:

public List<Track> getTrack()
{
    List<Track> trackList = new List<Track>();

    SqlConnection dbConn = connectToDb();

    string _selectQuery = string.Format("SELECT Date, Track, KeyID FROM hdData ORDER BY Track");

    try
    {
        dbConn.Open();
        SqlCommand cmd = new SqlCommand(_selectQuery, dbConn);
        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            Track Dat = new Track();
            Dat.Date = (string)reader[0];
            Dat.TrackName = (string)reader[1];
            Dat.KeyId = (int)reader[2];
            trackList.Add(Dat);
        }

        dbConn.Close();
     }
     catch (Exception e)
     {
        Console.WriteLine(e.ToString());
     }

     return trackList;
  }

If I take out the KeyId field it works fine… KeyId in the database is defined as a type int and is an auto incrementing field.

I even tried casting it to a varchar but same result…

What am I doing wrong?

Regards,
Dean

The exact error and Track class is as follows:

Ok, exact error is:

The maximum message size quota for incoming messages (65536) has been
exceeded. To increase the quota, use the MaxReceivedMessageSize
property on the appropriate binding element.

Server stack trace:
at System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream
inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception&
requestException)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message,
TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message
message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at IService1.getTrack()
at Service1Client.getTrack()

Inner Exception:
The maximum message size quota for incoming messages
(65536) has been exceeded. To increase the quota, use the
MaxReceivedMessageSize property on the appropriate binding element.

And the Track class is:

[DataContract]
public class Track
{
    string _Date, _TrackName;
    int _KeyId;

    [DataMember]
    public string Date
    {
        get { return _Date; }
        set { _Date = value; }
    }

    [DataMember]
    public string TrackName
    {
        get { return _TrackName; }
        set { _TrackName = value; }
    }

    [DataMember]
    public int KeyId
    {
        get { return _KeyId; }
        set { _KeyId = value; }
    }

}
  • 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-01T10:04:55+00:00Added an answer on June 1, 2026 at 10:04 am

    When you say “If I take out the KeyId field” do you mean remove from Track class? If so is it possible that the size of your Track list you are returning is close to your endpoint bindings MaxReceivedMessageSize (65536)? If this was the case then reducing the size of that List by removing a the _KeyId int from the Track class may reduce the overall returned data size below this limit.
    Try increasing this limit in the end point binding. You may need to do this for both server and client. Eg:

     maxBufferPoolSize="10000000" maxBufferSize="10000000" maxReceivedMessageSize="10000000">
        <readerQuotas maxDepth="32"
            maxStringContentLength="10000000" maxArrayLength="10000000"
            maxBytesPerRead="10000000" maxNameTableCharCount="10000000" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a WCF service that uses Entity Framework to query a SQL database.
I wrote a WCF service that returns a string[][][][][] (necessary for legacy reasons). Then
I have a WCF service, this is a method which I'd to call: [OperationContract]
I wrote a wcf service that uses BasicHttpBinding with some url and a client
I have a WCF web service that returns a stream. At the client side
I have started learning WCF. I wrote a simple service to query a SQL
In short: Trying to write a wcf service for a winform-app that invokes a
I have a need to connect to a WCF service I wrote without having
I'm in the process of writing a WCF service that will allow an ASP.Net
I'm working with a RESTful WCF service. One of the service methods returns byte[]

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.