Not all error messages are created equal, and some of them are less helpful than others.  Here is one I came across --  "Metadata contains a reference that cannot be resolved...  An exception was thrown in a call to a WSDL export extension:
System.ServiceModel.Description.DataContractSerializerOperationBehavior contract...  Type 'YourNamespace.YourClass' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute. "

If your class and data members are marked with appropriate attributes, check to see if your class has a default constructor.  At the time of writing this post, using .NET 4.5 or 4.5.1 (I did not check other .net versions), you will get this error if your data class doesn’t have a parameterized constructor.

Here is the exception with the call stack:

Error: Cannot obtain Metadata from http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex
If this is a Windows (R) Communication Foundation service to which you have
access, please check that you have enabled metadata publishing at the specified
address.  For help enabling metadata
publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata
Exchange Error    URI: http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex    Metadata contains a reference that cannot
be resolved:
'http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex'.    <?xml version="1.0" encoding="utf-16"?><Fault
xmlns="http://www.w3.org/2003/05/soap-envelope"><Code><Value>Receiver</Value><Subcode><Value
xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</Value></Subcode></Code><Reason><Text
xml:lang="en-US">An exception was thrown in a call to a WSDL
export extension:
System.ServiceModel.Description.DataContractSerializerOperationBehavior contract:
http://tempuri.org/:IService1</Text></Reason><Detail
xmlns:s="http://www.w3.org/2003/05/soap-envelope"><ExceptionDetail
xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink
i:nil="true"></HelpLink><InnerException><HelpLink
i:nil="true"></HelpLink><InnerException
i:nil="true"></InnerException><Message>Type
'ClassLibrary2.Phone' cannot be serialized. Consider marking it with the
DataContractAttribute attribute, and marking all of its members you want
serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking
it with the CollectionDataContractAttribute. 
See the Microsoft .NET Framework documentation for other supported
types.</Message><StackTrace>  
at
System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String
message, Type type)   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32
id, RuntimeTypeHandle typeHandle, Type type)  
at System.Runtime.Serialization.DataContract.GetDataContract(Int32 id,
RuntimeTypeHandle typeHandle, SerializationMode mode)   at System.Runtime.Serialization.DataContractSet.AddCollectionDataContract(CollectionDataContract
collectionDataContract)   at
System.Runtime.Serialization.DataContractSet.InternalAdd(XmlQualifiedName name,
DataContract dataContract)   at
System.Runtime.Serialization.DataContractSet.AddClassDataContract(ClassDataContract
classDataContract)   at
System.Runtime.Serialization.DataContractSet.InternalAdd(XmlQualifiedName name,
DataContract dataContract)   at
System.Runtime.Serialization.XsdDataContractExporter.Export(Type type)   at
System.ServiceModel.Description.MessageContractExporter.ExportType(Type type,
String partName, String operationName, XmlSchemaType&amp; xsdType)   at
System.ServiceModel.Description.DataContractSerializerMessageContractExporter.ExportBody(Int32
messageIndex, Object state)   at
System.ServiceModel.Description.MessageContractExporter.ExportMessage(Int32
messageIndex, Object state)   at
System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()   at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext
contractContext, IWsdlExportExtension
extension)</StackTrace><Type>System.Runtime.Serialization.InvalidDataContractException</Type></InnerException><Message>An
exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
contract: http://tempuri.org/:IService1</Message><StackTrace>   at
System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()   at
System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()   at
System.ServiceModel.Description.ServiceMetadataExtension.WSMexImpl.GatherMetadata(String
dialect, String identifier)   at
System.ServiceModel.Description.ServiceMetadataExtension.WSMexImpl.Get(Message
request)   at SyncInvokeGet(Object ,
Object[] , Object[] )   at
System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance,
Object[] inputs, Object[]&amp; outputs)  
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;
rpc)   at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;
rpc)   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;
rpc)   at
System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)</StackTrace><Type>System.InvalidOperationException</Type></ExceptionDetail></Detail></Fault>HTTP
GET Error    URI: http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex    There was an error downloading
'http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/mex'.    The request failed with HTTP status 400:
Bad Request.