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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:17:57+00:00 2026-05-27T04:17:57+00:00

This is a followup to my previous question , which got solved (thank you

  • 0

This is a followup to my previous question, which got solved (thank you for that) but now I am stuck at another error.

I’m trying to save an image in my database (called ‘Afbeelding’), for that I made a table which excists of:

  • id: int
  • souce: varbinary(max)

I then created a wcf service to save an ‘Afbeelding’ to the database.

    private static DataClassesDataContext dc = new DataClassesDataContext();

    [OperationContract]
    public void setAfbeelding(Afbeelding a)
    {
        //Afbeelding a = new Afbeelding();
        //a.id = 1;
        //a.source = new Binary(bytes);

        dc.Afbeeldings.InsertOnSubmit(a);
        dc.SubmitChanges();
    }

I then put a reference to the service in my project and when I press the button I try to save it to the datbase.

    private void btnUpload_Click(object sender, RoutedEventArgs e)
    {

        Afbeelding a = new Afbeelding();

        OpenFileDialog openFileDialog = new OpenFileDialog();

        openFileDialog.Filter = "JPEG files|*.jpg";

        if (openFileDialog.ShowDialog() == true)
        {
                //string imagePath = openFileDialog.File.Name;
                //FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
                //byte[] buffer = new byte[fileStream.Length];
                //fileStream.Read(buffer, 0, (int)fileStream.Length);
                //fileStream.Close();

            Stream stream = (Stream)openFileDialog.File.OpenRead();
            Byte[] bytes = new Byte[stream.Length];
            stream.Read(bytes, 0, (int)stream.Length);
            string fileName = openFileDialog.File.Name;


            a.id = 1;
            a.source = new Binary { Bytes = bytes };

        }


        EditAfbeeldingServiceClient client = new EditAfbeeldingServiceClient();

        client.setAfbeeldingCompleted +=new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_setAfbeeldingCompleted);
        client.setAfbeeldingAsync(a);
    }

    void client_setAfbeeldingCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
    {
        if (e.Error != null)
            txtEmail.Text = e.Error.ToString();
        else
            MessageBox.Show("WIN");
    }

However, when I do this, I get the following error:

    System.ServiceModel.FaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter :a. 
    The InnerException message was 'There was an error deserializing the object of type OndernemersAward.Web.Afbeelding. 
    The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'.  
    Please see InnerException for more details.    
    at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)    at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)    
    at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)  
  atOndernemersAward.EditAfbeeldingServiceReference.EditAfbeeldingServiceClient.EditAfbeeldingServiceClientChannel.EndsetAfbeelding(IAsyncResult result)
    at OndernemersAward.EditAfbeeldingServiceReference.EditAfbeeldingServiceClient.OndernemersAward.EditAfbeeldingServiceReference.EditAfbeeldingService.EndsetAfbeelding(IAsyncResult result)
    at OndernemersAward.EditAfbeeldingServiceReference.EditAfbeeldingServiceClient.OnEndsetAfbeelding(IAsyncResult result)    
    at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

I’m not sure what’s causing this but I think it has something to do with the way I write the image to the database? (The array length is too big big, I don’t really know how to change it)

Thank you for your help,
Thomas

  • 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-27T04:17:57+00:00Added an answer on May 27, 2026 at 4:17 am

    looks like you need to change default reader quotas in binding, set lengths to appropriate values for you:

     <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="5242880"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So this is a follow-up to a previous question that I asked: Trying to
Hey guys this is a followup to my previous question . I now have
This is a followup question from a previous question, which is hopefully a little
This question is a followup to a previous question , that was resolved thanks
this is actually a followup from a previous question but it contains different information
THis is a followup to my previous question Font-dependent control positioning. It's an attempt
This is a followup on the question: ASP.NET next/previous buttons to display single row
This is a followup to this question . I seem to be stuck on
This is a follow up to my previous question . Consider that I write
This is somewhat of a followup to my previous question , where people pointed

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.