Reputation: 4692
I am getting the following error when trying to launch the WCF Test client for a service and is driving me crazy. I have searched the web and sounds like the DataContract Name of HeaderRecord
exists twice in my project.
However, as doing a "find all" on this name only turned up one instance.
Can somebody please help me with this error. I'm at my wits end...
DataContract for type 'Ryder.Enterprise.DataTransferObjects.HeaderRecord[]' cannot be added to DataContractSet since type 'System.Collections.Generic.List`1[[Ryder.Enterprise.DataTransferObjects.HeaderRecord, Ryder.Enterprise.DataTransferObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' with the same data contract name 'ArrayOfHeaderRecord' in namespace 'http://www.ABC.com/SOA/DataContracts/2014/02/17' is already present and the contracts are not equivalent.
There is also no instance in my project of a name called ArrayOfHeaderRecord
.
Just for giggles, I decided to remove the Operation and Service Contract for this particular call into the method, and the WCF Test client came up successfully. When I put the contracts back in, that's when I get the error, but I still don't know why???
I even went back to an old version of my source code for this method (when it was coming up in the WCF Test client) and that failed as well.
I rebooted my machine and same thing is occurring. I don't understand this error. Even if I put back the contracts and just have a "shell" of my class that it's calling, I get the same error.
I don't know what to do anymore???
After tracing down everything in my solution, I found what the error was... My class was listed as follows: Notice the implementing of the List object which should not be there.
public class HeaderRecordCollection : List<HeaderRecord>
{
private List<HeaderRecord> headerRecords;
public HeaderRecordCollection()
{
}
[DataMember(Name = "HeaderRecords")]
public List<HeaderRecord> HeaderRecords
{
get
{
return headerRecords;
}
set
{
headerRecords = value;
}
}
}
I simply removed that where I only have one list. Since now only having one list for the object, no complaints from WCF!
Upvotes: 0
Views: 154
Reputation: 1107
Two years late, but hey ;)
Substitute Attribute DataContract for CollectionDataContract
Upvotes: 1