Anonymous
09-03-2004, 03:59 PM
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?
Eric Frost
09-03-2004, 08:08 PM
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.visual.studio.net.mappoint.html
Hope this helps!
Eric
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
Eric Frost
09-04-2004, 10:47 AM
Hmm, yeah I had no problems with it. I used it with the free command-line tools the .NET SDK, not VS.NET.
Eric
cd4000
09-06-2004, 06:29 PM
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