Mapinfo application file works in mapinfo 12.5 but not in mapinfo 16.0

113 views
Skip to first unread message

Eduard Dauwe

unread,
May 22, 2017, 4:58:22 AM5/22/17
to MapInfo-L
Hello,

I need to make an application run on a virtual machine on a new version of mapinfo. The application uses both native tables and ODBC connections to a microsoft SQL server database.
The application runs on mapinfo 12.5 without any problem, but it crashes whenever I try to run it on mapinfo 16.0. Then I get the message window: "Mapinfo stopped working".
The crash happens right after the log message "Vectoriseer", so it has something to do with the function CreatePointsFromGrid in my .mb file, which happens just after it. This function creates a point for every cell in the grid. This step is done to interpolate by municipality later.
I have copied this function here:

'****** Sub CreatePointsFromGrid **************************************************************
Sub CreatePointsFromGrid (ByVal sGridFileName as String, ByVal sPointTabName as String, ByVal sPointFileName as String)
OnError Goto ErrReport


 dim sProjection, sVal as string
 dim typg, puchIsNull as smallint
 dim hGrid, nCol, nRow, curCol, curRow as Integer
 dim xmin,ymin,xmax,ymax,zmin,zmax, zsVal, CellWidth, CellHeight  as float
 Dim iret, debug as logical
 Dim x, y, xx, yy, pdvalue As Float


 '
get the file handle
 iret
= GE_OpenGrid(sGridFileName, 1024, hGrid)
 sProjection
=space$(255)
 iret
=GE_GetCoordSysInfo(hGrid,sProjection,xmin,ymin,xmax,ymax)
 iret
=GE_GetDimensions(hgrid,nCol,nRow)
 iret
= GE_StartRead(hGrid)
 
if not iret then
 
Call Log (sGridFileName +" with handle "+hgrid+" cannot be open for reading", false)
 
exit sub
 
end if


 
Call Debug("CreatePointsFromGrid: Iterate trough grid")
 
If iret Then
 
Call Debug("Extents: " + xmin + ", " + ymin + ", " + xmax + ", " + ymax)
 
Call Debug("   nCol,nRow: "  + nCol + ", " + nRow)


 
CellWidth = (XMax-XMin)/nCol
 
CellHeight = (YMax-YMin)/nRow
 
Call Debug("     Cellsize: "  + CellWidth + " x " + CellHeight)
 
Call Debug("     Lijst van gridcellen, hun waarde en de coordinaten van hun centrum: ")
 
Call Debug("       (enkele voorbeelden)")


 
Create Table sPointTabName (Parameter Float) file sPointFileName
 
Create Map For sPointTabName CoordSys Earth Projection 19, 110, "m", 4.3569397222, 90, 49.8333333333, 51.1666666667, 150000.01256, 5400088.4378000004 Bounds (0, 0) (300000, 300000)
 
Set Coordsys Earth Projection 19, 110, "m", 4.3569397222, 90, 49.8333333333, 51.1666666667, 150000.01256, 5400088.4378000004


 
For curCol = 1 to nCol
 
For curRow = 1 to nRow
 iret
= GE_GetContinuousValue(hGrid, curCol, curRow, pdValue, puchIsNull)
 
If puchIsNull Then
 
' distinguish between zero values and NULL
 sVal ="-1" '
in fact this is NULL, no value
 
Else
 sVal
=str$(pdValue)
 
End If


 xx
= XMin + CellWidth * (curCol+.5) '11/06/2008 celwaarden verschoven in NO richting
 yy = Ymax - CellHeight *(curRow+.5) '
11/06/2008


 
Insert Into sPointTabName (obj,Parameter)
 
Values (CreatePoint(xx,yy),sVal)


 
If ((curCol < 4) and (curRow < 4)) OR ((nCol - 3 < curCol) and (nRow - 3 < curRow)) OR (curRow = curCol) then
 
Call Debug("       " + curCol + ", " + curRow + ", " + sVal + " at (" + xx + "," + yy + ")" )
 
End If
 
Next
 
If (curCol Mod 5 = 0) Then
 
Commit table sPointTabName
 
End If
 
Next
 
Commit table sPointTabName
 
 
' terminate read of grid
 iret = GE_EndRead(hGrid)
 Else
 Call Log(" StartRead(" + hGrid + ") failed", false)
 End If


 iret = GE_CloseGrid(hGrid)


Exit Sub
ErrReport:
 Call Log("     ERROR-Sub CreatePointsFromGrid: " + Err() + "   Description: " + Error$(),false)
 Err_ = True
 Resume Next
End Sub

Does anyone have any idea why this code is valid in mapinfo 12.5 and isn't in mapinfo 16.0? If you need, the whole .mb file is in attachment.

Regards,

Eduard
MakeMaps.mb

Thomas Bacon

unread,
May 22, 2017, 5:06:33 AM5/22/17
to mapi...@googlegroups.com

Hi Eduard,

 

I’ve only got MapInfo v 12.0 so I haven’t got a definite answer for you, but…

 

MapInfo recently made some big changes around raster handling, v15?, so perhaps the MIGrid.dll library has changed or no longer exists? Might be something to look into.

 

Kind regards,

 

Tom

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


______________________________________________________________________

Mouchel Limited I Registered in England No. 1686040 Registered Office: WSP House, 70 Chancery Lane, London, Wc2A 1AF Part of WSP Global Inc. Confidential This message, including any document or file attached, is intended only for the addressee and may contain privileged and/or confidential information. Any other person is strictly prohibited from reading, using, disclosing or copying this message. If you have received this message in error, please notify the sender and delete the message. Thank you.
______________________________________________________________________

Uffe Kousgaard

unread,
May 22, 2017, 5:20:52 AM5/22/17
to mapi...@googlegroups.com
Maybe hGrid has to be declared as IntPtr.
Slightly wild guess, since I don't know about migrid.dll, but if it is a pointer to a grid object, integer can no longer be used.

There could be much more that needs to be updated, though.

Regards
Uffe Kousgaard

Warren Vick

unread,
May 22, 2017, 6:04:31 AM5/22/17
to mapi...@googlegroups.com

Hello Eduard,

 

It sounds like a DLL incompatibility. Is it a different MIGRID.DLL for 64-bit environments? If it is the same name, are your paths such that the Pro 12.5 version is found first?

 

Regards,

Warren Vick

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of Eduard Dauwe
Sent: 22 May 2017 09:58
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Mapinfo application file works in mapinfo 12.5 but not in mapinfo 16.0

 

Hello,

--

Eduard Dauwe

unread,
May 22, 2017, 9:10:59 AM5/22/17
to MapInfo-L
Thank you for your quick replies. I checked where exactly in the code the crash happens. It is at this line of code inside the function CreatePointsFromGrid:
 iret=GE_GetCoordSysInfo(hGrid,sProjection,xmin,ymin,xmax,ymax)

This means that this previous line, 
iret = GE_OpenGrid(sGridFileName, 1024, hGrid)
which uses migrid.dll function, does not lead to a crash. 

As Uffe Kousgaard suggested, I declared hGrid as IntPtr, except for the functions GE_OpenGrid and GE_CloseGrid, as I got a compile error for the hGrid parameter of those functions. Nevertheless, the crash still happened.
Message has been deleted
Message has been deleted

Eduard Dauwe

unread,
May 22, 2017, 9:19:05 AM5/22/17
to MapInfo-L
Thanks for your reply Warren. I never thought about that. Is there any way I can check which migrid.dll file is found first? Mapinfo Pro 12.5 is installed in my Program files (x86) directory, whereas Mapinfo Pro 16.0 is installed in Program Files.
Maybe just removing Mapinfo Pro 12.5 (which is a trial version btw) can help?

Op maandag 22 mei 2017 12:04:31 UTC+2 schreef Warren Vick:

Uffe Kousgaard

unread,
May 22, 2017, 9:29:23 AM5/22/17
to mapi...@googlegroups.com
Hi,

migrid.dll is in the main mapinfo installation folder and it will load the correct one as long as you are not making your own copies in other folders. No problem.

You should be looking at the declare statements for the dll. They may be different for 64-bit.
I have looked but see no documentation about the dll, so where did you get it for 32-bit?

Regards
Uffe Kousgaard

Warren Vick

unread,
May 22, 2017, 11:22:26 AM5/22/17
to mapi...@googlegroups.com

Hello Eduard,

 

You could copy the migrid.dll from your Pro 16 environment and dump it in the same folder as your application. Given, however, your other comment about at least one of the other DLL functions being called successfully, I’m now doubting that this is the issue!

 

Regards,

Warren

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of Eduard Dauwe
Sent: 22 May 2017 14:16
To: MapInfo-L <mapi...@googlegroups.com>
Subject: Re: [MI-L] Mapinfo application file works in mapinfo 12.5 but not in mapinfo 16.0

 

Thanks for your reply Warren. I never thought about that. Is there any way I can check which migrid.dll file is found first? Mapinfo Pro 12.5 is installed in my Program files directory, whereas Mapinfo Pro 16.0 is installed in Program Files (x86).

Maybe just removing Mapinfo Pro 12.5 (which is a trial version btw) can help?

--

Message has been deleted

Eduard Dauwe

unread,
May 23, 2017, 10:08:11 AM5/23/17
to MapInfo-L
UPDATE: At first I only declared hgrid as IntPtr in the declaration part of the grid functions.I didn't do so in the function CreatePointsFromGrid itself. 
Now I changed the following part 
'****** Sub CreatePointsFromGrid **************************************************************
Sub CreatePointsFromGrid (ByVal sGridFileName as String, ByVal sPointTabName as String, ByVal sPointFileName as String)
OnError Goto ErrReport


 dim sProjection, sVal as string
 dim typg, puchIsNull as smallint
 dim hGrid, nCol, nRow, curCol, curRow as Integer
 dim xmin,ymin,xmax,ymax,zmin,zmax, zsVal, CellWidth, CellHeight  as float
 Dim iret, debug as logical
 Dim x, y, xx, yy, pdvalue As Float
        ...

to this (changes in yellow):
'****** Sub CreatePointsFromGrid **************************************************************
Sub CreatePointsFromGrid (ByVal sGridFileName as String, ByVal sPointTabName as String, ByVal sPointFileName as String)
OnError Goto ErrReport


 dim sProjection, sVal as string
 dim typg, puchIsNull as smallint
 dim hGrid as IntPtr
 dim hGridint as Integer

 dim nCol, nRow, curCol, curRow as Integer

 dim xmin,ymin,xmax,ymax,zmin,zmax, zsVal, CellWidth, CellHeight  as float
 Dim iret, debug as logical
 Dim x, y, xx, yy, pdvalue As Float
        ...
(The splitting of hgrid into two variables was needed because some grid functions need hgrid to be declared as an integer)

Now the application doesn't crash anymore in mapinfo 16.0, but after running the application the following message window appears: "Unable to read application file". 
The problem starts at the first function where hGrid is used as a parameter:
iret=GE_GetCoordSysInfo(hGrid,sProjection,xmin,ymin,xmax,ymax)
This function returns False.

To summarize, if the parameter hGrid is declared as an integer, mapinfo 16.0 crashes during the application run. If hGrid is declared as an IntPtr data type, the function GE_GetCoordSysInfo (and probably the other migrid.dll functions after it) returns False in mapinfo 16.0. 
The application works just fine in mapinfo 12.5 with hGrid defined as integer.
Any ideas?

Regards,

Eduard

Eric Blasenheim

unread,
May 24, 2017, 6:30:03 PM5/24/17
to MapInfo-L
Lots of interesting stuff here.
First of all, you never have to worry about a 32-bit DLL being loaded by a 64-bit program (like Pro 16) or vice versa. Windows will completely ignore them. For example, you can copy a 32-bit dll into the MBX folder or even the Pro install folder and it will not even be seen. If you try and give it a full path it will be ignored. 64-bit code will tell you that a specific DLL is "not an executable" .

Of course, you still, as always have to worry about the correct version of any dll. But the wrong "bitness" will never work, never be loaded. Any error would be right off the top.

The MiGrid.dll C API has been documented for many years but I forget where. It was put together for developers to build Grid apps and allows you not to worry about the format handlers. 
However, since the Unicode conversion of Pro (v15??) Pro itself uses a migridu.dll. The only difference is that any string parameters and returns are Unicode. Migrid.dll user migridu.dll and I think the only reason it is still there is for backward compatibility. That is, I do not think Pro ever uses it.  So that makes it possible for a bogus version of MiGrid.dll (64-bit) getting in the way. Make sure you don't have any of those in the MBX directory.

As far as IntPtr goes, yes that is a required change  because an Integer was kind of a workaround for a pointer. It was and is used as a numeric value but also to hold and pass back an oblique pointer which conveniently were the same size (32-bits)
In v16 a pointer must be 64bits and the IntPtr type was introduced to have a type that could be used on both 32 and 64 bit. Its size changes based on the version of Pro you are running. 
Repeat-  all "hgrid" need to be IntPtr types. 

As for what might still be an Integer I can think of nothing other than scalar types like row and column numbers.
Just so you know, since the MIGrid API was published before Unicode, you do not want to change the declaration to use Unicode characters. In the MB manual, there is documentation for using WideChars to tell Pro that a string from or to a DLL is Unicode. The MIGrid.dll exists for backward compatibility.

I don't see anything in the API that would still be an integer.  There are some smallint parameters that have not changed.  
There may be something outside the grid calls that is still a problem.

I hope this helps.
Eric Blasenheim
Pitney Bowes Software
Reply all
Reply to author
Forward
0 new messages