Select to view content in your preferred language

Unable to Create/open a fGBD in .NET Application

140
6
2 weeks ago
TOPOGRAPHICS
Occasional Contributor

Hello,

when I start to create/open a FileGeodatabase in c#, with the ArcGIS Pro SDK, e.g.

using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(gdbPath))))
{
// can open geodatabase
return true;
}

 

I get the following Exception:

'System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at ArcGIS.Core.Internal.Interop.GetInterface(Guid& id, Object& obj)
at ArcGIS.Core.Internal.Interop.get_Geodatabase()
at ArcGIS.Core.Data.GeodatabaseUtil.OpenDatastore(String path)
at ArcGIS.Core.Data.Geodatabase.Open(Uri uri)
at ArcGIS.Core.Data.Geodatabase..ctor(FileGeodatabaseConnectionPath connectionPath'

Courious the Exception occurs only on some PC, often with ArcGIS 3.1

Any help is welcome

Marcus

0 Kudos
6 Replies
StephenRhea_NV5
Frequent Contributor

What version was the fGDB created with? If it's a newer version, it may have some data types and functionality not available in 3.1.

0 Kudos
TOPOGRAPHICS
Occasional Contributor

Thanks for your reaction.

The fGDB was created with the same ArcGIS Pro Version, on the same machine, which is also used for the "new Geodatabase"-Function in c#. In the case it is ArcGIS Pro 3.1.41833

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi,

Are you trying to open geodatabase from core host application? Same error is here.

Check project .NET version. For 3.1.x was .NET 6.

 

0 Kudos
TOPOGRAPHICS
Occasional Contributor

Thank you for your reply. This is the same thing I was thinking about. but I haven't been able to try it yet.


So I need to compile multiple core host applications, one for each ArcGIS Pro version?
It's not a good solution, but apparently necessary.

0 Kudos
GKmieliauskas
Esri Regular Contributor

You need to compile core host application for each ArcGIS Pro SDK which use newest .NET version:

ArcGIS Pro SDK 2.9.x - .NET Framework 4.8

ArcGIS Pro SDK 3.0.x - ArcGIS Pro SDK 3.2.x - .NET 6.0

ArcGIS Pro SDK 3.3.x - ArcGIS Pro SDK 3.4.x - .NET 8.0

0 Kudos
SumitMishra_016
Regular Contributor

Hi @TOPOGRAPHICS ,

 

  • Ensure ArcGIS Pro and SDK Compatibility

    • Verify the ArcGIS Pro version on the problematic PCs:
      • Open ArcGIS Pro > About > Check the version.
    • Check that the ArcGIS Pro SDK version in your application matches the installed ArcGIS Pro version:
      • SDK 3.x works only with ArcGIS Pro 3.x.
  • Check File Geodatabase Version File Geodatabases have versions that define compatibility. For example:

    • ArcGIS Pro 3.1 supports File Geodatabases 10.0 and above.


Additionally, could you please check if you are using QueuedTask.Run before opening the geodatabase in your code, as shown below?

 

 

            try
            {
                await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
                {
                    // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase.
                    using (
              Geodatabase geodatabase =
                new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"\\path to gdb"))))
                    {
                        // Use the geodatabase.
                    }
                });
            }
            catch (GeodatabaseNotFoundOrOpenedException exception)
            {
                // Handle Exception.
            }

 

 

0 Kudos