Community of VE/MapPoint Users and Developers
This is a discussion on An invalid argument was encountered. within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I am using Mappoint with VB.Net. Iam having an issue with delete on a dataset item I am populating the ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| I am populating the Datasets with the following code: Dim objLoc As MapPoint.Location = mpMap.ActiveMap.GetLocation(CDbl(objLocationMaster .Latitude), CDbl(objLocationMaster.Longitude)) mpMap.ActiveMap.AddPushpin(objLoc, strPushPinName) I then call the following code: If mpMap.ActiveMap.DataSets.Count > 0 Then mpMap.ActiveMap.DataSets.Item(1).Delete() End If And at what appears to be at random times and intervals, and varying items in the data set, MapPoint will display the following: --------------------------- Microsoft MapPoint --------------------------- An invalid argument was encountered. --------------------------- OK --------------------------- Any ideas as to what would cause this to occur? Thanks in advance for any help. |
| |||
| Re: An invalid argument was encountered.
Hi, And which line of code is the offending one?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: An invalid argument was encountered.
Hi, Strange, since you check the Count property first there must be an Item(1). Maybe a bug that occurs in certain occasions. Best is to put the Delete() into an exception block, in that case you can also comment out the check on the Count;
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| ||||
| Re: An invalid argument was encountered.
Does VB.Net use 1-referencing or 0-referencing? It is a while since I used it. I know VB6 uses 1-referencing, but most other languages use 0-referencing. 0-referencing would cause this bug. As well as adding an exception, you could extract the reference and check it for null before calling Delete. Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
| Re: An invalid argument was encountered.
Thanks for the pointers. VB.Net is indeed 0 based. This syntax is confusing because the "1" is not a direct index it is a Key. DataSets is a collection of DataSet. I am not sure I am explaining that well, does that make sense? I believe if there was a null reference then when I check the count, it should throw a null reference exception, which is not the case. The other suggestion about catching the exception would work, however it is not an exception that is being thrown. An actual message box is coming up, in my UI. If I cannot figure out the root cause, it would be fine if there is a way to tell mappoint to suppress messages boxes. Could it be possible that this is a memory issue? The reason I ask, is this occurs at random times, but always near the end of large task. I am doubtful since I am in managed code, but you never know. And Thanks again for any help you can give. |
| ||||
| Re: An invalid argument was encountered.
The documentation says that Datasets is a collection and the Item method expects an index. I believe I've seen this before with MapPoint 'collections' - it means repeated iterations are often required to find an object in a MapPoint collection. The bit about null: I was thinking that Item() might succeed but return a null. If this is the case, then Delete will fail Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
| Re: An invalid argument was encountered.
Hi, Quote:
Quote:
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: An invalid argument was encountered.
Thanks for all the good feedback. I will try to iterate through the collection and see what I see and I will also monitor the memory use. I will post back with the results no matter the case. Thanks again. |
| |||
| Re: An invalid argument was encountered.
OK, I now believe that there is a race condition going on here. Not sure what it is, but whenever I stepped into the debugger the error would not occur. I add a sleep right before the delete and I did not get the error. If the sleep keeps the error from happening then that will be fine. I still would like to know what the actual cause was. Oh well. |
![]() |
| Tags |
| argument, encountered, invalid |
| ||||
| Posted By | For | Type | Date | |
| Waypoint Importer For MapPoint - MapPoint Articles - MP2K Magazine | This thread | Refback | 05-22-2008 07:13 AM | |
| Programming MapPoint via .NET - MapPoint Articles - MP2K Magazine | This thread | Refback | 05-20-2008 02:53 AM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 05-18-2008 07:08 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mappoint has encountered a problem and needs to close | Anonymous | MapPoint 2006/2009 Discussion | 4 | 05-05-2004 03:40 PM |
| MapPoint 2004 encountered an error | Anonymous | MapPoint 2006/2009 Discussion | 1 | 10-15-2003 03:20 PM |
| [Invalid Pointer] : what's wrong ? | Vincent BENNER | MapPoint 2006/2009 Discussion | 1 | 11-18-2002 11:47 AM |
Cheap Ski
Looking for a cheap ski? Holiday Hypermarket uses the UK's leading tour operators to provide you with fantastic low prices. Book a cheap ski holiday online today.
Luxury Travel Agent
Travel Counsellors is a leading Luxury Travel Agent. Whatever your travel needs, city break or luxury holiday, your personal Travel Counsellor can help.
Portugal Holidays
Lisbon is perhaps Europe's most pleasant and affordable city. Check out the fantastic architecture, delicious seafood and non-stop night-life. Book Portugal Holidays with us.
All Inclusive Maldives
Visit The Holiday Place.co.uk for great deals on all inclusive holidays to the Maldives. Book a holiday to the outstandingly beautiful Maldives.
Portugal
As well as providing some great weather Portugal has much to offer culturally. There are numerous museums, monuments and places of historical interest to explore. Despite the rich history there is a buzzing nightlife and great shopping too.
Family Holidays
Family holidays can be great fun. Check out your options at Travel.co.uk
Florida Holidays
Take a sunny holiday break! Find info on Florida holidays at On The Beach!