none
IDictionary has DataContract attribute serialization error - ASMX RRS feed

  • Question

  • I get the following error when calling our asmx service.  I'm the only one on the team getting this error.  Issue began about a week ago.  No changes to the code.  Can anyone point me in the right direction

    Cannot serialize member myobject.parameters of type System.Collections.Generic.Dictionary

    [DataContract]
        public class MyObject
        {
            [DataMember]
            public bool isSuccess { get; set; }
    
            [DataMember]
            public List<ErrorObject> Errors { get; set; }
    
            [DataMember]
            public Dictionary<string, string> Parameters { get; set; }
        }
     
        [DataContract]
        public class MyErrorObject
        {
            [DataMember]
            public int ErrorCode { get; set; }
    
            [DataMember]
            public string ErrorMessage { get; set; }
        }

    Wednesday, May 29, 2013 7:56 PM

All replies

  • Hi,

    If you are trying to use XmlSerializer to serialize the IDictionary object, this error may occurs. Take a look at the discussions here:

    http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/5115ff4c-75a6-4a96-9c6b-b840e04c650d

    If this is not the issue, I'd suggest you enable tracing for your service to help to locate the actual issue and use SvcTraceViewer.exe tool to analyze the diagnostic traces.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 30, 2013 8:23 AM
    Moderator
  • Not using XmlSerializer.  I did enable tracing and received an almost identical error message,

    System.NotSupportedException: Cannot serialize member MyObject.Parameters of type System.Collections.Generic.Dictionary`2

    Thursday, May 30, 2013 4:39 PM
  • Hi,

    >>I'm the only one on the team getting this error.  Issue began about a week ago.  No changes to the code. 

    From your description, the service seems ok, are there any difference for the operating system, way to host the service etc. with other teams?

    You may create a simplified service and consume the service with a client app at your machine to test if it works. 

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, May 31, 2013 10:17 AM
    Moderator
  • So far it looks like my teammates and I have the same pc setup.  My simple service works with no issues on my pc.  Trying to debug around this issue for now.

    Monday, June 3, 2013 7:17 PM
  • Hi,

    It's weird, do you check the .net framework version you have installed? Do you have .net 4.5 installed on your machine and how about the machines of your teammates? You may try the service at a machine without .net 4.5 installed.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 4, 2013 10:43 AM
    Moderator
  • Half of us are using 4.5 and half aren't.  Won't get a chance to try it today, I will have the opportunity to try this tomorrow.  Thanks.
    Tuesday, June 4, 2013 1:10 PM