title: Why do I get System.InvalidOperationException back from a WSDL call but not from the same call to another service?
body: <p>I have created service to get the country details information of various clients, but while hosting the service I am getting this exception. I am using basic http binding.</p>
  
  <pre><code>An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
  System.InvalidOperationException: An exception was thrown in a call to a 
  WSDL export extension:   
    System.ServiceModel.Description.DataContractSerializerOperationBehavior
    contract: http://tempuri.org/:IReferenceDataService ----&gt; 
       System.Runtime.Serialization.InvalidDataContractException: 
       Type 'Pariwaar.BusinessObject.CountryBO' cannot be serialized. 
       Consider marking it with the DataContractAttribute attribute, 
       and marking all of its members you want serialized with the 
       DataMemberAttribute attribute. See the Microsoft .NET Framework 
       documentation for other supported types.
     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.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type)
     at System.Runtime.Serialization.DataContract.GetDataContract(RuntimeTypeHandle typeHandle, Type type, SerializationMode mode)
     at System.Runtime.Serialization.DataContractSet.GetDataContract(Type clrType)
     at System.Runtime.Serialization.DataContractSet.GetItemTypeDataContract(CollectionDataContract collectionContract)
     at System.Runtime.Serialization.DataContractSet.AddCollectionDataContract(CollectionDataContract collectionDataContract)
     at System.Runtime.Serialization.DataContractSet.Add(XmlQualifiedName name, DataContract dataContract)
     at System.Runtime.Serialization.DataContractSet.Add(Type type)
     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.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext)
     at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
     --- End of inner ExceptionDetail stack trace ---
     at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
     at System.ServiceModel.Description.WsdlExporter.CallExportContract(WsdlContractConversionContext contractContext)
     at System.ServiceModel.Description.WsdlExporter.ExportContract(ContractDescription contract)
     at System.ServiceModel.Description.WsdlExporter.ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName)
     at System.ServiceModel.Description.WsdlExporter.ExportEndpoints(IEnumerable`1 endpoints, XmlQualifiedName wsdlServiceQName)
     at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
     at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
     at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
     at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
     at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest, String[] queries, Message&amp; replyMessage)
     at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
     at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.Get(Message message)
     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.ProcessMessage4(MessageRpc&amp; rpc)
     at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
     at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
     at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
     at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
  </code></pre>
  
  <p>I have <code>businessobject[datamember]</code> in another project. I have referred its dll here.</p>
  
  <p>You can view my class</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.ServiceModel;
  using System.Text;
  using Pariwaar.BusinessObject;
  using Pariwaar.DataAccessLayer;
  
  namespace Pariwaar.WCFServices.SVC
  {
      // NOTE: If you change the class name "ReferenceDataService" here, you must also update the reference to "ReferenceDataService" in Web.config.
      public class ReferenceDataService : IReferenceDataService
      {
          ReferenceData objDAL = new ReferenceData();
  
          public List&lt;CountryBO&gt; GetCountry()
          { return objDAL.GetCountry(); }
  
          public List&lt;StateBO&gt; GetState(int CountryId)
          { return objDAL.GetState(CountryId); }
  
          public List&lt;CityBO&gt; GetCity(int StateId)
          { return objDAL.GetCity(StateId); }
      }
  }
  </code></pre>
  
  <p>Why is this working fine with another WCF service, but giving me an error with another service?</p>