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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:37:11+00:00 2026-05-31T11:37:11+00:00

I have a program that calls a rest service and gets back a string

  • 0

I have a program that calls a rest service and gets back a string array. When I try to read the string array I get an exception Unexpected end of file. If I have the service return a string containing just the first item of the array it works. What am I missing about ReadAsDataContract<>() that is causing this exception?

    var returnElement = response.Content.ReadAsDataContract<string[]>();

The exception is an XMLException: Unexpected End of File.

Stack trace-

at System.Xml.EncodingStreamWrapper.ReadBOMEncoding(Boolean notOutOfBand)
       at System.Xml.EncodingStreamWrapper..ctor(Stream stream, Encoding encoding)
       at System.Xml.XmlUTF8TextReader.SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
       at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)
       at System.Runtime.Serialization.DataContractContentExtensions.ReadAsDataContract[T](HttpContent content, DataContractSerializer serializer)
       at System.Runtime.Serialization.DataContractContentExtensions.ReadAsDataContract[T](HttpContent content)
       at RestConsumption.Program.GetDevices() in **********\documents\visual studio 2010\Projects\RestPractice\RestConsumption\Program.cs:line 55
       at RestConsumption.Program.Main(String[] args) in *********\documents\visual studio 2010\Projects\RestPractice\RestConsumption\Program.cs:line 26
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  • 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-31T11:37:12+00:00Added an answer on May 31, 2026 at 11:37 am

    I solved this in a really easy way that I still don’t understand why it worked. I simply did

        string[] returnElement = response.Content.ReadAsDataContract<string[]>();
    

    instead of

        var returnElement = response.Content.ReadAsDataContract<string[]>();
    

    and it worked fine. If anyone tells me why this worked I’ll give them credit for answering this question.

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

Sidebar

Related Questions

I have a program that does recursive calls for 2 billion times and the
I have written a c# program that calls a c++ dll that echoes the
I have a Python script that calls an executable program with various arguments (in
I have a Java program that calls a C++ program to authenticate users. I
I have a program that constantly calls a function. In my function i use
I have an AS3 program that calls a function multiple times. The function must
I have a python program that calls into a c++ library, which wishes to
broken to bare-bones scene: I have a program in c# that calls a .exe
I have one program that calls one tar.. something like popen(tar -zcvf) I want
I have a C program which has a function call that is defined in

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.