none
Object Property in Contract Issue RRS feed

  • Question

  • I am new to web services and I am stuck at defining an object property named MyValue in my WCF service.

    The data contract class looks sort of like this:

    [DataContract(Namespace = Namespaces.DEFAULT_NAMESPACE)]
    public class MyRequestMessage : DefaultRequestMessage
    {
        [DataMember(IsRequired = true)]
        public int Id { get; set; }
    
        [DataMember(IsRequired = true)]
        public int Nr { get; set; }
    
        [DataMember(IsRequired = true)]
        public string Name { get; set; }
    
        [DataMember(IsRequired = true)]
        public object MyValue { get; set; }
    }

    After deploying the service and updating the reference in my test solution I get following error message:

    System.InvalidOperationException: Type cannot be added to list of known types since another type with the same data contract name is already present. If there are different collections of a particular type - for example, List<Test> and Test[], they cannot both be added as known types. Consider specifying only one of these types for addition to the known types list.

     Any ideas how to solve this error?

    Thanks in advance guys

    Wednesday, August 13, 2014 9:21 AM

Answers

All replies