Problem Statement: Issues with Creating a MapInfo Instance in MapInfo 2023

72 views
Skip to first unread message

Jayant Grover

unread,
Jan 7, 2025, 4:23:02 AMJan 7
to MapInfo-L

I am currently working on a MapInfo-based application using .NET and Visual Studio 2017. The application is developed with C#.NET Framework 4.7.2 on a Windows 10 system. The goal is to interact with MapInfo Professional to perform specific tasks. However, I am encountering challenges while creating the MapInfo instance in the 2023 version.

The same code or approach worked fine in earlier versions, but in this version, the MapInfo instance is not initializing as expected.

Here are the details of the problem:

  • Environment:

    • MapInfo Professional 2023
    • Visual Studio 2017
    • C#.NET Framework 4.7.2
    • Windows 10
  • Issue: When attempting to create the MapInfo instance, the initialization process fails. The instance is not created, and the application cannot proceed further. No specific error messages are displayed.

  • Expected Outcome: The MapInfo instance should initialize correctly, enabling interaction as intended.

  • Troubleshooting Attempts: I have tried using various DLLs provided with MapInfo Professional 2023 to address potential compatibility or functionality issues, but the problem persists.

Has anyone else experienced similar issues with the 2023 version? Are there any changes in the DLLs, or initialization process specific to this version? Could the issue be related to the .NET framework version or Visual Studio compatibility? Any guidance or suggestions would be greatly appreciated.


1000233906.jpg1000233905.jpg


MapmyIndia goes global & introduces Mappls

Peter Horsbøll Møller

unread,
Jan 7, 2025, 9:06:43 AMJan 7
to mapi...@googlegroups.com

Hey Jayant

 

In the IntegratedMappingWpf example that comes with MapBasic v2023, I can see the MapInfo Pro is initiated using this statement:

 

      // Initialize the IMapInfoApplication interface.

      Application = MapInfoCore.Initialize(this, this);

      if (Application == null)

      {

            return;

      }

 

We do supply four samples with MapBasic.

 

Can you check them out and see if this approach works for you?

 

I can’t tell from you screenshot if this is calling a constructor of your own?

_MIApp = new MapInfoApplication()

 

Cheers

Peter

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Jayant Grover
Sent: 7. januar 2025 10:09
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Problem Statement: Issues with Creating a MapInfo Instance in MapInfo 2023

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 


MapmyIndia goes global & introduces Mappls

--
--
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.
To view this discussion visit https://groups.google.com/d/msgid/mapinfo-l/94408d7d-76af-46a6-b7fd-09b5d8105114n%40googlegroups.com.

Jayant Grover

unread,
Jan 8, 2025, 3:51:41 AMJan 8
to MapInfo-L
Hi Peter 

The samples provided by MapInfo demonstrate creating instances for integrated MapInfo . Alternatively, We have initialized MapInfo using its registry ID which is compatible with MapInfo 16.0 and MapInfo 2023 

Please find the attached code for reference.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace MapInfo_Temp
{
    public partial class Form1 : Form
    {
        private dynamic _MapInfoApp;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                _MapInfoApp = Activator.CreateInstance(Type.GetTypeFromProgID("MapInfo.Application.x64"));
                System.Threading.Thread.Sleep(10);
                _MapInfoApp.Do("Set ProgressBars OFF");
                _MapInfoApp.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Unable To Initialize MapInfo Instance ({ex.ToString()})");
                return;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            _MapInfoApp.Do(@"Open Table "Path of Your File" as tableName");
            _MapInfoApp.Do("Select * from tableName");
            _MapInfoApp.Do("Select count(*) from selection");
            int count = int.Parse(_MapInfoApp.Eval("Selection.count"));
            MessageBox.Show($"Count = {count}");
            MessageBox.Show("print(\"Hello\")");
            MessageBox.Show("Process Completed MapInfo Initialize Successfully.");
        }
    }
}

Thanks for your Support 

Regards 
Jayant Grover 
Reply all
Reply to author
Forward
0 new messages