Answered by:
Cannot obtain Metadata from http://localhost:55408/ShopProcessService.svc

Question
-
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'.
Bill Yeager
Thursday, March 13, 2014 6:15 PM
Answers
-
EDIT 2 - Resolution
-------------------
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!
Bill Yeager
- Marked as answer by Amy PengMicrosoft employee Friday, March 14, 2014 2:21 AM
Thursday, March 13, 2014 7:50 PM
All replies
-
Check your app.config file and make sure there is no duplication of "HeaderRecord" DataContract.
Gaurav Khanna | Microsoft VB.NET MVP | Microsoft Community Contributor
Thursday, March 13, 2014 6:37 PM -
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???
Bill Yeager
Thursday, March 13, 2014 6:42 PM -
EDIT 2 - Resolution
-------------------
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!
Bill Yeager
- Marked as answer by Amy PengMicrosoft employee Friday, March 14, 2014 2:21 AM
Thursday, March 13, 2014 7:50 PM