Search code examples
c#comdictionaryscalabilitymappoint

MapPoint 2011 COM Scalable?


I've been tasked with writing a web service that can be called from one of our two plant locations that will allow our shipping department to get the most efficient route for a set of deliveries. We've also discussed the possibility of setting up territories and assigning deliveries to territories and territories to drivers.

My question, in its simplest form, is this: MapPoint 2011 allows you to use its object model through COM. I'm not terribly familiar with this type of programming but it seems to create a new instance of the application each time the logic is called. Is this type of usage scalable? What will happen if ten calls are received simultaneously?

I've included some sample code pulled from MSDN below as a point of reference.

//set up application
MapPoint.Application objApp = new Application();
objApp.Visible = false;
objApp.UserControl = false;

MapPoint.Route objRoute;
MapPoint.Map objMap;

objMap = objApp.ActiveMap;
objRoute = objMap.ActiveRoute;

objMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;

//Get locations for route
object item = 1;
objRoute.Waypoints.Add(objMap.FindResults("Redmond, WA").get_Item(ref item), 
    "Redmond, WA");
objRoute.Waypoints.Add(objMap.FindResults("Seattle, WA").get_Item(ref item), 
    "Seattle, WA");
objRoute.Waypoints.Add(objMap.FindResults("Portland, OR").get_Item(ref item), 
    "Portland, OR");

// Calculate the route
objRoute.Calculate();

//Asks if you want to save the map? How would you say no programmatically?
objApp.Quit();

Solution

  • No, it is not scaleable and it is a very bad idea. Running any program that relies heavily on a desktop session (such as MapPoint 2011) in a server environment has issues, mainly because a desktop session isn't available.

    Additionally, desktop application such as this are not developed for server environments, so they consume resources differently (and usually more aggressively) than you might expect.

    In your case, if you receive ten calls at the same time, then you will have ten instances of the application run on your server (and then shut down, but still). This generally is not scaleable for applications of this type.

    MapPoint 2011 falls in the same category as Office, in that it should not be run in a server environment, as per Microsoft's own recommendation.