Select to view content in your preferred language

VersionManager crash when GetVersions Method is called

996
8
07-17-2023 01:52 AM
Cristian_Galindo
Occasional Contributor III

There is an add-in that create a version, in the process of creating the version, it verifies the existing of the version calling the existing versions.

Current it is throwing at exception when connected to ONE geodatabase:

Unhandled exception at 0x00007FFDF2C423EB (CoreInterop.dll) in ArcGISPro_2.9.5.32739_47FF8EC5-67F0-4891-8FB6-0A95A0AC38D0_07_13_2023_15_41_05.dmp: 0xC0000005: Access violation reading location 0x0000000000000000.

 

at the beginning I though the issue was related to my code but I was able to isolate the issue, Even I create a small snippet in PowerShell that horribly crash when executed:

Add-Type -Path 'C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll'
Add-Type -Path 'C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll'
[ArcGIS.Core.Hosting.Host]::Initialize()

[ArcGIS.Core.Data.DatabaseConnectionProperties]$connectionProperties = [ArcGIS.Core.Data.DatabaseConnectionProperties]::new([ArcGIS.Core.Data.EnterpriseDatabaseType]::SQLServer)

$connectionProperties.AuthenticationMode = [ArcGIS.Core.Data.AuthenticationMode]::DBMS
$connectionProperties.Instance = "YOUR_SQL_SERVER"
$connectionProperties.Database = "YOUR_DATABASE"
$connectionProperties.User = "YOUR_USER"
$connectionProperties.Password = "USER_PASSWORD"

$gdb =  [ArcGIS.Core.Data.Geodatabase]::new($connectionProperties); 

$versionManager = $gdb.GetVersionManager()
$existingVersions = $versionManager.GetVersions()

$existingVersions | %{$_.GetName()}

 

the issue here is that this error only happens with one database. What should i look into the database to detect the reason of this failure, and if possible solve it.

One really nice thing about it is the ArcGIS Pro allows me to list and create versions using its interface.

0 Kudos
8 Replies
Aashis
by Esri Contributor
Esri Contributor

@Cristian_Galindo Can you connect the database through the Pro UI and create versions manually in the Pro?

You could list version names using VersionManager.GetVersionNames() method, rather VersionManager.GetVersions(), which will attempt to connect to every version in the system.

 

 

0 Kudos
Cristian_Galindo
Occasional Contributor III

@Aashis as I already mentioned

One really nice thing about it is the ArcGIS Pro allows me to list and create versions using its interface.

I confirm: I can connect to the database and create versions manually.

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

Although the Pro SDK doesn't provide support for Powershell, it happens to work for you. Can you convert the script into a C# based Corehost application and see if you can get additional debug information related to the geodatabase?

If not, can we get a sample dataset to reproduce the issue in our machine?

0 Kudos
Cristian_Galindo
Occasional Contributor III

Hello @Aashis 

here you have the same snippet but in C#:

void Main()
{
	ArcGIS.Core.Hosting.Host.Initialize();
	ArcGIS.Core.Data.DatabaseConnectionProperties connectionProperties = new(ArcGIS.Core.Data.EnterpriseDatabaseType.SQLServer);
	connectionProperties.Instance = "YOUR_SQL_SERVER";
	connectionProperties.Database = "YOUR_DATABASE";
	connectionProperties.User = "YOUR_USER";
	connectionProperties.Password = "USER_PASSWORD";

	var gdb = new ArcGIS.Core.Data.Geodatabase(connectionProperties);
	
	var versionManager = gdb.GetVersionManager();
	var existingVersions = versionManager.GetVersions();
	foreach (var version in existingVersions)
	{
		Console.WriteLine(version.GetName());
	}
}

 

As I already mention this happens just in one database, I have tried to spot the difference between a functional one an the faulty one, but I can not narrow the difference.

0 Kudos
Cristian_Galindo
Occasional Contributor III

following the recommendation of @Aashis I changed my code to use VersionManager.GetVersionNames() method: the result is the same I am still getting an exception:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

 

 

0 Kudos
Cristian_Galindo
Occasional Contributor III

checking the versions on the geodatabase I found: the records in the database are not the same that ArcGIS Pro 2.9 shows:

Cristian_Galindo_0-1689679855918.png

Cristian_Galindo_1-1689679887732.png

 

0 Kudos
Cristian_Galindo
Occasional Contributor III

when I delete the row that is not shown by ArcGIS Pro, then my snippets and my code work without issue. but then a nice - important too - question came to my mind, should I do that in production?

 

0 Kudos
Cristian_Galindo
Occasional Contributor III

After reading a little bit I found the invisible version belongs to a replica of the geodatabase:

Cristian_Galindo_2-1689682889889.png

https://support.esri.com/en-us/knowledge-base/faq-what-are-the-syncsend-and-syncreceive-versions-in-...

https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/synchronization-and-version...

I confirm that in the dialog Manage replicas:

Cristian_Galindo_3-1689683120199.png

 

I unregister the the replica, and the row was deleted:

Cristian_Galindo_4-1689683204455.png

Now the script and the add-in are working

I will proceed to test this in ArcGIS Pro 3.*, and possible to create bug, because the SDK functionality in the VersionManager is not compatible with the replica functionality.

😖

 

0 Kudos