title: getting Error(There was an error generating the XML document.) fetch data from server side in extjs in asp.net
body: <p>I am working with Extjs 4.1 and asp.net
  I am trying to fill grid panel from database but getting error. I am using webservice to fetch data.</p>
  
  <p>Error: </p>
  
  <pre><code>System.InvalidOperationException: There was an error generating the XML document. ---&gt; System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set.
     at System.Data.DataTable.WriteXmlSchema(XmlWriter writer, Boolean writeHierarchy)
     at System.Data.DataTable.System.Xml.Serialization.IXmlSerializable.WriteXml(XmlWriter writer)
     at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
     at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_DataTable(Object o)
     at Microsoft.Xml.Serialization.GeneratedAssembly.DataTableSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
     at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
     --- End of inner exception stack trace ---
     at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
     at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
     at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o)
     at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
     at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
     at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
     at System.Web.Services.Protocols.WebServiceHandler.Invoke()
  </code></pre>
  
  <p>my webservice code</p>
  
  <pre><code> [WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet = true, XmlSerializeString = false)]
      public DataTable displayData() {
          db obj = new db();
          return obj.getCountry();
      }
  </code></pre>
  
  <p>calling web service from js file</p>
  
  <pre><code> var store = Ext.create('Ext.data.Store', {
              pageSize: 20,
              model: 'ForumThread',
              autoLoad: true,
              proxy: {
                  type: 'ajax',
                  url: 'report.asmx/displayData',
                  dataType: "json",
                  contentType: "application/json; charset=utf-8",
                   //url: '/grid.json',
                  reader: {    
                  root: 'data'   ,          
                      type: 'json',
                      method: "GET",
                      totalProperty: 'totalCount'
                  }
              }
          });
  </code></pre>
  
  <p>even i remove this line from webservice <code>[ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet = true, XmlSerializeString = false)]</code> but still same error.</p>
  
  <p><strong>I didnt use XMLSerializer in my code then also it will give me error like There was an error generating the XML document.</strong> </p>