title: Is the GeoCoding Maps API only valid for websites?
body: <p>I have a Windows Forms (WinForm) billing product that currently running .Net Framework 4.6.1 and is being maintained in Visual Studio 2015.</p>
  
  <p>We have been asked to modify the mapping tool that takes a physical address and returns a Latitude/Longitude grid coordinates.</p>
  
  <p>I got myself a key for testing, and applied that in my code.</p>
  
  <pre><code>private void GoogleGeoCodeSearch(LocationRecord currentRecord, String key)
  {
      var street = String.Format("{0}", currentRecord.street_name).Trim();
      var city = String.Format("{0}", currentRecord.city).Trim();
      var state = String.Format("{0}", currentRecord.state).Trim();
      var postal = String.Format("{0}", currentRecord.postal_code).Trim();
      var country = (state.Length == 2 &amp;&amp; STATES.Contains(state)) ? "USA" : String.Format("{0}", currentRecord.country).Trim();
      var address = String.Format("{0}, {1}, {2}, {3} {4}", street, city, state, postal, country).Replace("-", String.Empty).Replace("'", String.Empty);
      var requestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}&amp;sensor=false&amp;region={1}&amp;key={2}", Uri.EscapeDataString(address), country, key);
  
      var request = System.Net.WebRequest.Create(requestUri);
      using (var response = request.GetResponse())
      {
          var ok = false;
          var title = String.Format("{0}::Google API WebRequest", _title);
          var source = "response stream";
          var element = "XDocument";
          var xdoc = System.Xml.Linq.XDocument.Load(response.GetResponseStream());
          if (xdoc != null)
          {
              source = element;
              element = "GeocodeResponse";
              var geoResponse = xdoc.Element(element);
              if (geoResponse != null)
              {
                  source = element;
                  element = "result";
                  var result = geoResponse.Element(element);
                  if (result != null)
                  {
                      source = element;
                      element = "geometry";
                      var geometry = result.Element(element);
                      if (geometry != null)
                      {
                          source = element;
                          element = "location";
                          var locationElement = geometry.Element(element);
                          if (locationElement != null)
                          {
                              source = element;
                              element = "lat/lng";
                              var lat = locationElement.Element("lat");
                              var lng = locationElement.Element("lng");
                              if ((lat != null) &amp;&amp; (lng != null))
                              {
                                  Double latitude, longitude;
                                  Double.TryParse(lat.Value, out latitude);
                                  Double.TryParse(lng.Value, out longitude);
                                  SaveCoordinates(currentRecord, latitude, longitude);
                                  ok = true;
                              }
                          }
                      }
                  } else
                  {
                      result = geoResponse.Element("status");
                      if (result != null)
                      {
                          var msg = result.Value;
                          result = geoResponse.Element("error_message");
                          if (result != null)
                          {
                              msg = String.Format("{0}{1}{1}{2}", msg, Environment.NewLine, result.Value);
                          }
                          MessageBox.Show(msg, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                      }
                  }
              }
          }
          if (!ok)
          {
              MessageBox.Show(String.Format("No [{0}] information found in [{1}] element.", element, source), title, MessageBoxButtons.OK, MessageBoxIcon.Information);
          }
      }
  }
  </code></pre>
  
  <p>Every time I get to this line, I get a <code>NULL</code> response:</p>
  
  <pre><code>var result = geoResponse.Element(element);
  </code></pre>
  
  <p>This is the explanation:</p>
  
  <pre><code>&lt;GeocodeResponse&gt;
    &lt;status&gt;REQUEST_DENIED&lt;/status&gt;
    &lt;error_message&gt;The provided API key is invalid.&lt;/error_message&gt;
  &lt;/GeocodeResponse&gt;
  </code></pre>
  
  <h2>Can the Google GeoCoding API be used in a Windows Forms application?</h2>