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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:07:17+00:00 2026-06-15T00:07:17+00:00

This one really has me stumped. I’m trying to deserialize the following JSON string

  • 0

This one really has me stumped. I’m trying to deserialize the following JSON string which I get from a ASP.NET Web Service:

"{\"d\":{\"__type\":\"KPCServer.LogonResult\",\"User\":{\"UserId\":\"affaa328-5b53-430e-991a-22674ede6faf\",\"Email\":\"test@test.com\",\"Alias\":\"Mike\",\"FullName\":\"Mike Christensen\",\"Password\":\"secret\",\"Location\":\"Redmond, WA\",\"ImageUrl\":null,\"DateOfBirth\":\"\\/Date(-62135568000000)\\/\",\"LastLogon\":\"\\/Date(1350450228000)\\/\",\"UserSince\":\"\\/Date(1197980020000)\\/\",\"MailingList\":true,\"Bio\":\"Test\"},\"NewUser\":false,\"Ticket\":\"FJEjfje87fjef88fe8FAF8fA88fAjk+AFJ9fja9Fa9Ff99aJF9aFjfA99fjaBFJ7zqmlcHn9Dfw=\"}}"

I have the following types:

public class User
{
   public Guid UserId { get; set; }
   public string Email { get; set; }
   public string Alias { get; set; }
   public string FullName { get; set; }
   public string Password { get; set; }
   public string Location { get; set; }
   public string ImageUrl { get; set; }
   public DateTime DateOfBirth { get; set; }
   public DateTime LastLogon { get; set; }
   public DateTime UserSince { get; set; }
   public bool MailingList { get; set; }
   public string Bio { get; set; }
}

[DataContract(Name="KPCServer.LogonResult")]
public class LogonResult
{
   [DataMember] public User User { get; set; }
   [DataMember] public bool NewUser { get; set; }
   [DataMember] public string Ticket { get; set; }
}

[DataContract]
[KnownType(typeof(LogonResult))]
public class Result<T>
{
   [DataMember]
   public T d { get; set; }
}

I then try to deserialize the string using:

using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
{
   DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Result<T>));
   Result<T> result = serializer.ReadObject(stream) as Result<T>;

   return result.d;
}

Note: In the above method, T is of type LogonResult.

However, I get the following exception on ReadObject:

System.Runtime.Serialization.SerializationException was unhandled by user code
  HResult=-2146233076
  Message=JSON contains a '__type' member specifying the data contract name ':KPCServer.LogonResult'. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'KPCServer.LogonResult' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer. You can also often eliminate this error by avoiding the use of derived types where the JSON is produced.
  Source=System.ServiceModel.Web
  InnerException: 

If I run:

json = json.Replace("_type", "_blah");

Then everything works fine. This is using Silverlight on Windows Phone 8.

  • 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-15T00:07:25+00:00Added an answer on June 15, 2026 at 12:07 am

    This is due to the fact that:

    "\"__type\":\"KPCServer.LogonResult\""
    

    doesn’t contain a data contract namespace. This is fixed by modifying the DataContractAttribute on LogonResult:

    [DataContract(Name = "KPCServer.LogonResult", Namespace="")]
    public class LogonResult
    {
        [DataMember]
        public User User { get; set; }
        [DataMember]
        public bool NewUser { get; set; }
        [DataMember]
        public string Ticket { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one really has me stumped. I have a documents table which hold info
I'm really stumped by this one! The StackFrame object ( MSDN Link ) has
I'm trying to access an external DLL function from F#. This one has me
I am really stumped on this one. I have a simple python wrapper which
This one really has me stumped. Scenario: Windows 7 64-bit Lotus Notes (8.5.2) Eclipse
This one really has me stumped. I have not ran across this problem on
This one has really got me stumped. I have certain forms that are being
This one has me stumped. I've got a java.sql.ResultSet and I'm pulling string values
this one is really easy. I'm trying to create a Regular Expression that will
Boy, this one is really weird. I expect the following code to print 1990,

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.