Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 5 of 5

Mappoint and a .Net Console App

This is a discussion on Mappoint and a .Net Console App within the MapPoint Desktop Discussion forums, part of the Map Forums category; I am trying to use Mappoint in a .Net Console app. I don't need to see the map, I just ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Mappoint and a .Net Console App

    I am trying to use Mappoint in a .Net Console app. I don't need to see the map, I just need mileage.

    This is what I have

    Dim objMap As New AxMapPoint.AxMappointControl()
    objMap.NewMap(MapPoint.GeoMapRegion.geoMapNorthAme rica)

    The latter command errors immediately with the following message:

    "Exception of type InvalidActiveXStateException was thrown."

    I have no other Mappoint related statements before this point.
    Anyone have any thoughts on that?

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    There's several .Net / MapPoint desktop apps on this website, I think the simplest and most relevant to your inquiry might be:

    http://www.mp2kmag.com/a69--automate....mappoint.html

    Hope this helps!

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    EdB
    EdB is offline Member Green Belt
    Join Date
    Aug 2002
    Posts
    56
    Eric,

    I appreciate the response. I was able to get my situation to work by adding a windows form to my console app, adding a Mappoint control to that form, and just never showing the form.

    But I wanted to to try your solution. Did someone just write that, or did they actually try it? Here's why I ask. When I copy and paste the solution as is, I get several compile errors. 6 with the project setting "Strict" on (which I normally use), and 3 with it off. Here are the errors.

    1&2) Dim WithEvents oMpApp As MapPoint.Application
    Dim WithEvents oMap As MapPoint.Map

    Withevents variable does not raise any events

    3,5&6) oMpApp = GetObject(, "MapPoint.Application")
    myLoc = oMap.FindAddressResults(, , , states(I), , "USA")(1)
    oMap.SaveAs(states(I), 2)


    Option Strict On disallows implicit conversions from 'System.Object' to 'MapPoint.Application'

    4) oMpApp = New MapPoint.Application()

    'New' cannot be used on an interface.

    I can get around the other 5......I don't know how to get around this one.


    Ed

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    Hmm, yeah I had no problems with it. I used it with the free command-line tools the .NET SDK, not VS.NET.

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  5. #5
    cd4000 is offline Junior Member White Belt
    Join Date
    Aug 2004
    Posts
    6
    I second EdBick's situation as I am getting the same error when trying to use New on MapPoint.Application.

    I had to resort to CreateObject() function to get around this problem, which is inconsistent with many MapPoint samples out there.

    The other strange problem I couldn't resolve is why GetPictureFromObject() always returns some default map of the North-Western US region even if the actual map is totally different (and yes, I have saved it before calling GetPictureFromObject()).

    Alex

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96