Mapinfo 12 and VB.net

706 views
Skip to first unread message

Glen O

unread,
Aug 19, 2013, 11:10:41 AM8/19/13
to mapi...@googlegroups.com
Hello
 
anyone take mapinfo 12 out for a test drive using VB.net?
 
have the examples in the manual been updated ?
 
Evil G

ICW Keith

unread,
Sep 19, 2013, 6:25:02 PM9/19/13
to mapi...@googlegroups.com
I have an application vb.net application that was built using mapinfo 11.5.1 and works great.  Something has changed from 11.5.1 to 12.0 such that it does not work in MapInfo 12. the complaint falls on the following line of code.
 

MIObj1 = System.Runtime.InteropServices.

Marshal.GetActiveObject("MapInfo.Application")

 I have yet to figure this one out.
 
I get an error  MK_E_UNAVAILABLE(jpg attached).
 
Again it worked fine in 11.5.1, I suspect something in 12.0 has changed.
 
Most frustrating when urgency is at hand.
 
Keith Tozier
International Computer Works, Inc.
 

MI_12_Error.jpg

ICW Keith

unread,
Sep 19, 2013, 6:29:40 PM9/19/13
to mapi...@googlegroups.com
In addition if you use the command line to use the (MapInfo Universal TRanslator) IMUT.exe, the file name has changed to FME.exe.  I have modified my code to look for either file.  The first time on a version 12 install it did not work, I simply copied the IMUT.exe into the UT folder where mapinfow.exe is installed. 

Glen O

unread,
Sep 19, 2013, 7:34:51 PM9/19/13
to mapi...@googlegroups.com
 
replace
 
MIObj1 = System.Runtime.InteropServices.

Marshal.GetActiveObject("MapInfo.Application")

 
with this
 
MIObj1 = New MapInfo.MapInfoApplication
 
don't forget to setup your imports
 
imports mapinfo
imports system.runtime.interopservices
 
 

 

 

 

 

ICW Keith

unread,
Sep 19, 2013, 9:16:23 PM9/19/13
to mapi...@googlegroups.com

I will give that a try.

Peter Horsbøll Møller

unread,
Sep 20, 2013, 4:50:31 AM9/20/13
to mapi...@googlegroups.com
I have come across that error before.
In that case the problem was caused by an old version of MapInfo on the computer.

When the new and the old version of Mi Pro were uninstalled and the new reinstalled it worked

Peter Horsbøll Møller
Pitney Bowes Software



Date: Thu, 19 Sep 2013 15:25:02 -0700
From: keith....@icwmaps.com
To: mapi...@googlegroups.com
Subject: [MI-L] Re: Mapinfo 12 and VB.net
--
--
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/groups/opt_out.

ICW Keith

unread,
Sep 20, 2013, 2:25:16 PM9/20/13
to mapi...@googlegroups.com
Okay,

I tried using the "MIObj1 = New MapInfo.MapInfoApplication and that gets rid of any error, however MapInfo is already runnning and I need the current instance of the running copy.

Again it is error free but the MIobj1 does not know the instance that I am trying to set itself to so there seems to be no connection to the current running mapinfo and nothing happens in MapInfo.


I am finding there are several differences in the way MapInfo 11.5.1 and MapInfo 12.0 have been implemented in the VB.NET environment.

In MapInfo 11.5.1 the interop.mapinfo.dll was not listing under COM objects but added in via the browse and labeled as a .NET assembly.

Now MapInfo 12.0 shows up under .COM and I have added it in as such.


I have tried

Public Shared Function GetRunningMapInfo() As MapInfo.MiPro.Interop.MapInfoApplication

            ' Dim MIobj1 As MapInfo.MiPro.Interop.MapInfoApplication = Nothing

            If Process.GetProcessesByName("MAPINFOW").Length <> 0 Then
                'Get a pointer to the Word application
                Try
                    'MIObj1 = System.Runtime.InteropServices.Marshal.GetActiveObject("Mapinfo.Application")
                    MIObj1 = GetObject("Mapinfo.Application")
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            Else
                'Create a new instance of the word application
                MIobj1 = Nothing
            End If

            GetRunningMapInfo = MIobj1

        End Function


Then I get "Can not create ActiveX component" error message.

Then immediately after that "Object Reference not set to an instance of an object"

I have all of my imports

Imports System.IO
Imports System.Text
Imports System.Timers
Imports System.Net.Sockets
Imports System.Windows.Forms
Imports MapInfo
Imports MapInfo.MiPro
Imports MapInfo.MiPro.Interop
Imports MapInfo.MiPro.Interop.MapInfoApplication
Imports Microsoft.VisualBasic

So I do not think that is an issue.

I am still working on it, but thought I would update my findings.







ICW Keith

unread,
Sep 20, 2013, 6:59:32 PM9/20/13
to mapi...@googlegroups.com
Okay I think I have learned another way to get the connection to mapinfo pro 12.0 and found it in an earlier MapInfo -L thread. 

I can not take the credit for it. (Cliff Brewer and Bo Victor Thomsen had this discussion)

On mapinfo -L the issue is titled "Linking VB to the right instance of MapInfo"

It was written in C# I just had to convert into vb.net and this worked, I believe this is also discussed and only discussed in the MapBasic 12.0 integrated mapping section.

In MapBasic, one would pass the MapInfo Window ID  to the VB App in a sub.

                    MIWindowID=SystemInfo(SYS_INFO_APPIDISPATCH)


and with the sub in VB it is passed to:

                    Dim MIDispatchPtr = New System.IntPtr(MIwindowID)
                    MIObj1 = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(MIDispatchPtr)
                    MIObj1.Do("Print " & chr(34) & "Hey Ma, I am on top of the World" & chr(34))

Glen O

unread,
Sep 21, 2013, 8:37:30 AM9/21/13
to mapi...@googlegroups.com
I am confused you will be running a Mapbasic program in mapinfo and then you want to call a VB.net program and "hook" in to it?
 
if you going to process a lot of data using inter-op is not the way to go you will find it very slow  
 

ICW Keith

unread,
Sep 23, 2013, 6:48:03 PM9/23/13
to mapi...@googlegroups.com

Actually the application is a DLL with a socket for communication.
Reply all
Reply to author
Forward
0 new messages