MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




An invalid argument was encountered.

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 ...


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 (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 05-14-2008
EdB EdB is offline
Member
Green Belt
 
Join Date: Aug 2002
Posts: 56
Question An invalid argument was encountered.

I am using Mappoint with VB.Net. Iam having an issue with delete on a dataset item

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.
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 05-15-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,105
Re: An invalid argument was encountered.

Hi,

And which line of code is the offending one?
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 05-15-2008
EdB EdB is offline
Member
Green Belt
 
Join Date: Aug 2002
Posts: 56
Re: An invalid argument was encountered.

Sorry about that. The offending line of code is:

mpMap.ActiveMap.DataSets.Item(1).Delete()

Thanks.
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 05-15-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,105
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;
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 05-15-2008
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 850
Blog Entries: 7
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 05-15-2008
EdB EdB is offline
Member
Green Belt
 
Join Date: Aug 2002
Posts: 56
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 05-15-2008
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 850
Blog Entries: 7
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 05-16-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,105
Re: An invalid argument was encountered.

Hi,

Quote:
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.
There is no way to tell mappoint to suppress it. I've never seen this message however.

Quote:
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.
Maybe, I don't know. But you can check out with task manager if it happens when your application or mappoint has eaten a lot of memory.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 05-16-2008
EdB EdB is offline
Member
Green Belt
 
Join Date: Aug 2002
Posts: 56
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 05-16-2008
EdB EdB is offline
Member
Green Belt
 
Join Date: Aug 2002
Posts: 56
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.
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
argument, encountered, invalid


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/invalid-argument-encountered-7688.html

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

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
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


All times are GMT -5. The time now is 09:14 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

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!


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