Hi Karl I hope you don't mind but I'm turing this out to the list because it may be of wider interest - even if its only to Lars Nielsen :-)
(I used to work at OS (96 to 98) - the system you're upgrading isn't VAPOR is it?!? (View and Plot Request - the acronym was suggested by Steve Short, who also left a few years back). I wrote part of that code, to declare an interest.) This OLE integration is a bit of a grey area to say the least. We have probably ended up knowing more than most about integrated mapping (at least with VB) and I can't give a definitive answer. OLE is pretty good most of the time and its also the only route available short of using DDE. I did try using DDE communication with an MBX to sidestep the issue but DDE strings can only be 256 characters which is no good for instance when building themes. So general points - 1. Don't use 6.5. As I recall OS have a site licence so use 7 (or even 7.5 which should be there by now). 6.5 OLE automation seemed much flakier for some reason. Any lawyers listening - all IMHO etc. Anyway why are you listening - get on with your work. 2. If you are using callbacks, catch all of these events and pass them on using a timer, rather than raise or process the event out of the callback routine. This puts the event into another thread and has helped enormously - somewhere between MI and VB there is some thread blocking going on. We can't use a multithreaded EXE because of another unrelated dependence but I think this is a good wheeze anyway. eg In the standard setstatustext callback routine, catch the string from MI and put it into a global variable. Enable the timer (at design time set the interval to be 100ms, which seems to work for us - it CAN'T be 0). In the timer routine, immediately disable the timer and raise the event from here. Catch the event on your form and process it (eg set the text showing the cursor position, or - if you are catching a custom tool click, process the click). Its a redirection of the event. Otherwise the OLE session with MI is blocked until the event is completely processed, which can cause timeouts, Method ~ etc. 3. Use the SetFocus API switch to put control onto MapInfo - GetAssyncKey doesn't seem to do much for us but is probably an idea along the same lines. SetFocus needs the HWND of the MapInfo session but that is a property you can retrieve through EVAL when MapInfo instantiates using CreateObject. I put all calls to MI inside a class so that I can ensue SetFocus always happens. 4. If you always call do/eval through a single function (or one for each) then you can trap the error as soon as it happens. (You can't always resolve it though) 5. Sometimes - its your (or my) (or 'ones') crap code that triggers the error. This is why the error handling around DO and EVAL will help. 6. We got it most often with DIM statements when the system is busy. 7. Maybe theres only so much you can do - The mechanism is as follows (from Eric Blasenhiem at MI) - "You probably know this already, but OLE calls to Pro are out� of process calls. So, the OLE subsystem, VB and� MapInfo Pro are allocating memory for parameters� marshaling (strings in our case) and as these are Unicode and Pro is not, there is a bunch of copying for each method. Also, VB� always used to use the "GetIDsOfNames" mechanism for� OLE calls. This meant that every time a call is made,� a lookup from name of method to OLE Dispatch ID was� done to execute the function. On our end, the ID is used against the type library to find the right run time function. C++� callers, however, hard code the Dispatch ID at compile� time. In the early days, VB would sometimes fail in� the GetIDsOfNames part. However, I have heard that VB6 has a much more optimal mechanism. That is, they start using the old method but then cache the ID.� I can also see� this going bad or getting trashed. Anyway, long story short, there are a number of possibilities� for failure if the system is busy, using too much� memory or perhaps there is a leak somewhere.� I� know that this does not really help but it may give you some background." Hope this all helps Paul Crisp Syntegra Innovation Place Delta Bank Road Newcastle NE11 9DJ Tel 0191 461 4522 Fax 0191 460 1987 -----Original Message----- From: Karl Harrison [mailto:[EMAIL PROTECTED] Sent: 03 October 2003 10:21 To: CRISP, Paul -Syntegra UK Subject: MI-L OLE - Method ~ of object failed Hi Paul I found your question on the directions website http://lists.directionsmag.com/discussion/read.php?f=7&i=33827&t=33827 regarding the spasmodic "Method ~ of object failed" error. We are getting exactly the same error - we have been trying to upgrade a system written in VB6 and running MapInfo 5.0 on a Windows NT machine to Windows 200 or XP and MapInfo 6.5 or 7.0. Can you tell me if the suggestion of using the getasynckeystate(KeyValue) worked or if you found a better solution other than a rewrite in Delphi! Your help is much appreciated. Thanks Karl Harrison Phone 023 8079(2043) mailto:[EMAIL PROTECTED] If you have received this email in error, please delete it immediately and notify the sender. This email may contain confidential information and if you are not the intended recipient, you must not copy, distribute or rely on it. As email is not a 100% secure communications medium, you accept that there are risks in communicating by email by doing so. We advise you to check that emails and attachments are virus-free before opening them. No contracts can be entered into on our behalf by email. Opinions expressed in this email are not necessarily endorsed by us unless otherwise specifically stated. We reserve the right to read and monitor any email or attachment entering or leaving our systems without prior notice. Ordnance Survey Romsey Road Southampton SO16 4GU Tel: 023 8079 2000 http://www.ordnancesurvey.co.uk ******************************************************************** This email may contain information which is privileged or confidential. If you are not the intended recipient of this email, please notify the sender immediately and delete it without reading, copying, storing, forwarding or disclosing its contents to any other person Thank you Check us out at http://www.syntegra.com ********************************************************************
