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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:53:23+00:00 2026-06-04T21:53:23+00:00

I have the following code to convert a list of messages into json :

  • 0

I have the following code to convert a list of messages into json :

Public Class MessageService
    <OperationContract()> _
    Public Function GetMessage(Id As Integer) As String



        Dim msg As New Message()
        Dim stream As New MemoryStream()
        Dim serializer As New DataContractJsonSerializer(GetType(NewMessage))

        Dim dtMessages = msg.getUnreadMessages("3A3458")

        Dim list As New ArrayList

        Dim m As New NewMessage()
        m.Id = 1
        m.Text = "mmsg"
        list.Add(m)
        list.Add(m)
        serializer.WriteObject(stream, list)

        stream.Position = 0
        Dim streamReader As New StreamReader(stream)
        Return streamReader.ReadToEnd()
    End Function
End Class

But I got the following error :

    The server was unable to process the request due to an internal error. 
 For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, 
or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.
  • 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-04T21:53:25+00:00Added an answer on June 4, 2026 at 9:53 pm

    Here:

    Dim serializer As New DataContractJsonSerializer(GetType(NewMessage))
    

    You indicate to the serializer that you want to serialize a NewMessage instance.

    And here:

    serializer.WriteObject(stream, list)
    

    you are passing an Arraylist. This obviously is ambiguous. I would recommend you modifying your method so that it returns directly a strongly typed collection and leave the JSON serialization to the binding instead of writing plumbing code in your data contract:

    Public Class MessageService
        <OperationContract()> _
        Public Function GetMessage(Id As Integer) As List(Of NewMessage)
            Dim list As New List(Of NewMessage)
            Dim m As New NewMessage()
            m.Id = 1
            m.Text = "mmsg"
            list.Add(m)
    
            Return list
        End Function
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that is meant to convert milliseconds into hours, mins
I have the following working code to convert a list with nested maps (actually
Suppose I have following code: public class CBase: AbstractC,IRenderable { //code here } public
I have the following piece of code: public List<myTask> MyTask { get; set; }
I have the following code: public class CategoryNavItem { public int ID { get;
Imagine the following code: class foreach_convert { public static void method2() { List<IComparable> x
I have the following code : using System.Collections.Generic; public class Test { static void
I have written the following code: public List<Card> DealCards(int numCardsToDeal) { return shuffle.RemoveRange(0,numCardsToDeal-1); }
I'm trying to convert a String to an Integer. I have the following code:
I have the following code sample: float val = 16777216.0F; var badResult = Convert.ToDecimal(val);

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.