Select to view content in your preferred language

How to know plugin data source not installed in the machine .net sdk

368
1
Jump to solution
06-28-2023 09:48 AM
ShaneTsh
New Contributor II

Hi,

I have a plugin data source project and also its addin project. Addin project uses a reference of the plugin project. But if only addin is installed and not its plugin, Pro is crashing.

How to check if the plugin is not installed in the machine in the addin project to stop Pro to crash?

@Wolf  @GKmieliauskas  @UmaHarano 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can surround the creation of the PluginDatastore by try ... catch as it is implemented here: 
arcgis-pro-sdk-community-samples/Plugin/SimplePointPluginTest/TestCsv2.cs at master · Esri/arcgis-pr...

In essence you need this

try
{
  // you must use await in order to catch any exceptions in the new thread
  await QueuedTask.Run(() =>
  {
    using (var pluginws = new PluginDatastore(...))
    {
      using (var table = pluginws.OpenTable(table_name))
      {
      }
    }
  });
}
catch (Exception ex)
{
  MessageBox.Show(ex.Message);
}

you could also check Pro's AssemblyCache folder for the Guided folder of the Plugin, but that's a bit more involved.  Either way there shouldn't be a crash.

 

View solution in original post

0 Kudos
1 Reply
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can surround the creation of the PluginDatastore by try ... catch as it is implemented here: 
arcgis-pro-sdk-community-samples/Plugin/SimplePointPluginTest/TestCsv2.cs at master · Esri/arcgis-pr...

In essence you need this

try
{
  // you must use await in order to catch any exceptions in the new thread
  await QueuedTask.Run(() =>
  {
    using (var pluginws = new PluginDatastore(...))
    {
      using (var table = pluginws.OpenTable(table_name))
      {
      }
    }
  });
}
catch (Exception ex)
{
  MessageBox.Show(ex.Message);
}

you could also check Pro's AssemblyCache folder for the Guided folder of the Plugin, but that's a bit more involved.  Either way there shouldn't be a crash.

 

0 Kudos