MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




C# Late Binding Application

This is a discussion on C# Late Binding Application within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, didn't find anything like that here but here some kinky different way to do things. Maybe some of you ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (9) Thread Tools Display Modes
  9 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 08-06-2007
Member
Yellow Belt
 
Join Date: Jul 2007
Posts: 45
C# Late Binding Application

Hi,
didn't find anything like that here but here some kinky different way
to do things. Maybe some of you can use it, but use it wise.

using System.Reflection;

Get MapPoint:
object mapPoint = Activator.CreateInstance(Type.GetTypeFromProgID("M apPoint.Application.EU.13"));

Now you can work with it, unless it's the right Id ^^

Get a Property:
object activeMap = mapPoint.GetType().InvokeMember("ActiveMap", BindingFlags.GetProperty | BindingFlags.OptionalParamBinding, null, mapPoint, new object[0]);

Call a Method:
object results = activeMap.GetType().InvokeMember("FindAddressResul ts", BindingFlags.InvokeMethod | BindingFlags.OptionalParamBinding, null, activeMap, new object[6] { "Musterweg", "Stuttgart", "", "", "", "Deutschland" });

Set a Property:
activeMap.GetType().InvokeMember("Saved", BindingFlags.SetProperty, null, activeMap, new object[1] { true });

Let's get dirty
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 08-07-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C# Late Binding Application

Hi,

Thanks for sharing. Can you come up with an idea where this can be interesting or even encouraged ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 08-08-2007
Member
Yellow Belt
 
Join Date: Jul 2007
Posts: 45
Re: C# Late Binding Application

It's usefull if you just want to have data from MapPoint without
the connection to your controls.
You don't have to reference MapPoint in your project and it's
quite direct an simple to programm.
Bad Point: long instructions

(Needed to display the Map on a Floating Panel so this was
a dead end at that part, if some of you know how to connect
it with a control just post it, i didn't had the time to test or
search)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 08-09-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Re: C# Late Binding Application

hi,

thanks for clarifying. I do not understand the reason completely. Can you enlighten some more ? This can be interesting to put on the FAQ.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 08-10-2007
Member
Yellow Belt
 
Join Date: Jul 2007
Posts: 45
Re: C# Late Binding Application

Hmm i'm no Pro so i do not know ^^
...
I think you asked why i tried to Late Binded it ...
Scenario:
Want to use MapPoint if the Client has MP2006
and don't even want to show him the options
of using it if not. Like a feature.
Now, if i reference it in the project (c# visual studio
2005) an compile it and execute it on another
pc that doesn't have mp2006, it crashs on start-up.
This is as far as i understood the Problem.
If i late binde it, and catch the problematic parts
(when i make an instance of mp or call it) in try-catch
blocks, i can prevent the application from crashing.

The code above uses Late Binding and you don't
have to visualize it, hang mp in a form, etc..
You just need the Distance or DrivingTime, just call it
with the functions above. But beware, long instuctions
if you don't encapsule them your code will explode. ^^

Btw. MapPoint ocx is a b****, had to enbedd it in a
form to prevent it from closing dirty, like "save-popup"
at different states of the closing-mainform, mp-crash
at the end of my application ... just learned 1 thing
from it, give it a form, hide it, use it, give the control
back to the form before closing other forms and let
the form kill the mp ocx .... confusing ...

(just updated the segment info in my table after optimizing,
directions list (of the route) didn't have the last waypoint
of the route and other kinky ways of saving stuff.
Needed a 2-while-algo to just get the distance an time
between the waypoints ... not very clever done)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
application, binding, late


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/c-late-binding-application-6135.html

Posted By For Type Date
MapPoint User Community - MP2K Magazine This thread Refback 08-15-2007 10:55 PM
User:Mapelves - MapElves This thread Refback 08-12-2007 02:28 PM
MapPoint Download - MP2K Magazine This thread Refback 08-08-2007 09:01 AM
Using Autoroute 2003 Data in MapPoint 2002 - MapPoint Articles - MP2K Magazine This thread Refback 08-06-2007 11:21 AM
A More Compact Method for Obtaining Lat/Long - MapPoint Articles - MP2K Magazine This thread Refback 08-06-2007 11:13 AM
MapPoint Help - MP2K Magazine This thread Refback 08-06-2007 09:41 AM
A More Compact Method for Obtaining Lat/Long - MapPoint Articles - MP2K Magazine This thread Refback 08-06-2007 04:13 AM
Lat/Long in MapPoint 2002 - MapPoint Articles - MP2K Magazine This thread Refback 08-06-2007 03:57 AM
A More Compact Method for Obtaining Lat/Long - MapPoint Articles - MP2K Magazine This thread Refback 08-06-2007 03:55 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Application cannot call MP joe1156 MapPoint 2006/2009 Discussion 3 05-24-2007 08:29 AM
Sample application in c# alt-088 MapPoint 2006/2009 Discussion 3 09-16-2004 04:35 PM
Cant See Mappoint.Application from VB Anonymous MapPoint 2006/2009 Discussion 2 04-15-2004 11:15 AM
Can a MapPoint control be conditionall loaded or late bound? frankp MapPoint 2006/2009 Discussion 2 02-28-2004 10:50 PM
Pb with another application Anonymous MapPoint 2006/2009 Discussion 0 12-17-2002 04:53 AM


All times are GMT -5. The time now is 09:54 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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