Microsoft Developer Network > 포럼 홈 > Visual C# General > Exception Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.
질문하기질문하기
 

답변됨Exception Field not found: 'System.Runtime.Serialization.XmlObjectSerializerContext.serializerKnownDataContracts'.

  • 2008년 6월 14일 토요일 오전 12:45HydPhani 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    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

답변

  • 2008년 6월 14일 토요일 오전 9:15Calle Mellergardh 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Sorry, but what exactly is the execption (namespace.type) and what is the exact exception message?

    /Calle
    • 답변으로 표시됨Xun Ye 2008년 6월 18일 수요일 오전 2:59
    •  
  • 2008년 6월 15일 일요일 오전 12:21Shailen Sukul 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
     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
    • 답변으로 제안됨Shailen Sukul 2008년 6월 15일 일요일 오전 12:21
    • 답변으로 표시됨Xun Ye 2008년 6월 18일 수요일 오전 2:59
    •  

모든 응답

  • 2008년 6월 14일 토요일 오전 9:15Calle Mellergardh 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    Sorry, but what exactly is the execption (namespace.type) and what is the exact exception message?

    /Calle
    • 답변으로 표시됨Xun Ye 2008년 6월 18일 수요일 오전 2:59
    •  
  • 2008년 6월 15일 일요일 오전 12:21Shailen Sukul 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
     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
    • 답변으로 제안됨Shailen Sukul 2008년 6월 15일 일요일 오전 12:21
    • 답변으로 표시됨Xun Ye 2008년 6월 18일 수요일 오전 2:59
    •