Microsoft Developer Network > Página principal de foros > Visual C# General > Exception Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.
Formular una preguntaFormular una pregunta
 

RespondidaException Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.

  • sábado, 14 de junio de 2008 0:45HydPhani Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código
    Hi All, 

        I am calling a business layer method call as below: 

    List<UsageCategorySummary> prodUsageCategorySummary = ProductDomain.Instance.GetUsageCategories();

    hidUsageCategory.Value = this.JsonSerializerHelper(prodUsageCategorySummary);


    Helper function code 

    private string JsonSerializerHelper(System.Object objRef)

    {

    string result = string.Empty;

    using (MemoryStream memoryStream = new MemoryStream())

    {

    DataContractJsonSerializer serializer = new DataContractJsonSerializer(objRef.GetType());

    // Resulting to an exception...

    // //  Exception Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.
    serializer.WriteObject(memoryStream, objRef);
    memoryStream.Position = 0;

    using (StreamReader streamReader = new StreamReader(memoryStream))

    {

    result = streamReader.ReadToEnd();

    }

    }

    return result;

    }

    Exception occurring at the above colored line... any thoughts?!


    HydPhani

Respuestas

  • sábado, 14 de junio de 2008 9:15Calle Mellergardh Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    Sorry, but what exactly is the execption (namespace.type) and what is the exact exception message?

    /Calle
    • Marcado como respuestaXun Ye miércoles, 18 de junio de 2008 2:59
    •  
  • domingo, 15 de junio de 2008 0:21Shailen Sukul Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
     Seems like your object cannot be serialized. This can happen if you have a child List collection.
    See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=302308&SiteID=1

    Please remember to mark as answered. -- With Regards Shailen Sukul (Shane) Software Architect/Developer/Consultant/Trainer (BSc | Mct | Mcpd | Mcts (Sharepoint (IP), Biztalk, Web, Win, Dist Apps) | Mcsd.NET | Mcsd | Mcad) Ashlen Consulting Services Pty Ltd (http://www.ashlen.com.au) MSN | Skype | GTalk Id: shailensukul Ph: +61 421 277 812 Fax: +61 3 9011 9732 Blog: http://shailensukul.blogspot.com
    • Propuesto como respuestaShailen Sukul domingo, 15 de junio de 2008 0:21
    • Marcado como respuestaXun Ye miércoles, 18 de junio de 2008 2:59
    •  

Todas las respuestas

  • sábado, 14 de junio de 2008 9:15Calle Mellergardh Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    Sorry, but what exactly is the execption (namespace.type) and what is the exact exception message?

    /Calle
    • Marcado como respuestaXun Ye miércoles, 18 de junio de 2008 2:59
    •  
  • domingo, 15 de junio de 2008 0:21Shailen Sukul Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
     Seems like your object cannot be serialized. This can happen if you have a child List collection.
    See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=302308&SiteID=1

    Please remember to mark as answered. -- With Regards Shailen Sukul (Shane) Software Architect/Developer/Consultant/Trainer (BSc | Mct | Mcpd | Mcts (Sharepoint (IP), Biztalk, Web, Win, Dist Apps) | Mcsd.NET | Mcsd | Mcad) Ashlen Consulting Services Pty Ltd (http://www.ashlen.com.au) MSN | Skype | GTalk Id: shailensukul Ph: +61 421 277 812 Fax: +61 3 9011 9732 Blog: http://shailensukul.blogspot.com
    • Propuesto como respuestaShailen Sukul domingo, 15 de junio de 2008 0:21
    • Marcado como respuestaXun Ye miércoles, 18 de junio de 2008 2:59
    •