1

I am working on a WPF application that uses the built-in WebBrowser to display Bing Maps. The code can draw polygons on the map, which we are trying to export as KML using the Microsoft.Maps GeoXML module:

Microsoft.Maps.loadModule('Microsoft.Maps.GeoXml', function () {
       // Pass in the map to export all data into an XML string
       try {
           var xml = Microsoft.Maps.GeoXml.write(map, {
               xmlFormat: Microsoft.Maps.GeoXmlFormat.kml,
               roundLocations: true,
               indentChars: '    '
           });
       }
       catch (e) {
           alert(e)
       }

However, this code gives the following error: Port number should be an integer

I have looked online and can't find anything about what this error means. The Microsoft documentation doesn't seem to require any kind of port number, and the map itself (which supposedly uses the same setup) works fine (aside from a few script errors).

Possibly helpful information

  1. The .htm that we load into the WebBrowser is set up to call methods from a C# helper class. We also sometimes invoke the javascript methods from C#.
  2. The actual map functions properly for the most part, but there is a script error when hovering over the dropdown to select the map type. I'm not sure if this points to a problem in our overall setup or not.
  3. We have nearly identical javascript in our web project, and get no errors. The only difference is the callbacks to our C# class.

Attempted Fixes

I tried to get a stack trace from the error, but it was undefined.

I have used the code at this link to make sure that the web browser is using the proper version of Internet Explorer. However, I don't get these errors running the .htm in Internet Explorer.

  • 1
    Take a look at whatever your URL is. When you see _port number_ it's often in the context of a URL. For example in http://example.com:8080/this/that, the "8080" (following the colon) is the port number. My guess is your URL is a little mangled, you've got a colon there, and whatever follows is being interpreted as a bad port number. Just a guess though – Flydog57 Feb 27 '19 at 15:44
  • @Flydog57 Thank you for the suggestion! Unfortunately, I only have two URL's in the whole .htm file: 'http://www.bing.com/api/maps/mapcontrol?branch=release' and 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'. Since our web project works fine with these same URL's, I don't think they're the problem. Would you happen to know of any way to look at which URL's I'm trying to access? I suppose that should be my next step. – Joshua Sharo Feb 27 '19 at 16:12
  • See if this helps: https://stackoverflow.com/a/18333982/1768303 – noseratio Mar 04 '19 at 08:17

0 Answers0