Getting HRESULT E_FAIL error when trying to open database connection via connection file

1427
1
Jump to solution
11-13-2020 02:42 AM
TomGeo
by
Occasional Contributor III

I developed an Addin in AGP 2.5 where I am using connection files to open database connections at runtime. So far that worked perfect. The connection files are stored on a network drive, referenced in the Addin with absolute paths.

DatabaseConnectionFile connectionFileValidering = new DatabaseConnectionFile(new Uri(AppSettings.Default.sde_validation));

Now that I am doing some maintenance on the Addin I am running into the following error when trying to open the enterprise database:

Database test_db = new Database(connectionFileValidation);


'Database test_db = new Database(connectionFileValidation)' threw an exception of type 'ArcGIS.Core.Data.GeodatabaseException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233088
HelpLink: null
InnerException: {"Error HRESULT E_FAIL has been returned from a call to a COM component."}
Message: "A geodatabase exception has occurred."
Source: "ArcGIS.Core"
StackTrace: " at ArcGIS.Core.Data.Database..ctor(DatabaseConnectionFile databaseConnectionFile)"
TargetSite: {Void .ctor(ArcGIS.Core.Data.DatabaseConnectionFile)}

With respect to the error message I found some stuff that is not related to ArcGIS, but did not help either.
Anybody here can point me the direction of a solution?

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry for the late reply ... i just tried this using 2.6 and it worked fine.  My sample code has the UriKind.Absolute parameter added in the Uri constructor.  Let me know if you still have problems with this and i try it in 2.5.

 

try
{
		var workspaceConnectionString = await QueuedTask.Run(() =>
		{
				var sdePath = @"\\tsclient\C\Data\FeatureTest\sde-test.sde";
				var dbGdbConnection = new DatabaseConnectionFile(new Uri(sdePath, UriKind.Absolute));
				return new Geodatabase(dbGdbConnection).GetConnectionString();
		});
		MessageBox.Show(workspaceConnectionString);
}
catch (Exception ex)
{
		MessageBox.Show($@"Error: {ex}");
}

 

View solution in original post

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

Sorry for the late reply ... i just tried this using 2.6 and it worked fine.  My sample code has the UriKind.Absolute parameter added in the Uri constructor.  Let me know if you still have problems with this and i try it in 2.5.

 

try
{
		var workspaceConnectionString = await QueuedTask.Run(() =>
		{
				var sdePath = @"\\tsclient\C\Data\FeatureTest\sde-test.sde";
				var dbGdbConnection = new DatabaseConnectionFile(new Uri(sdePath, UriKind.Absolute));
				return new Geodatabase(dbGdbConnection).GetConnectionString();
		});
		MessageBox.Show(workspaceConnectionString);
}
catch (Exception ex)
{
		MessageBox.Show($@"Error: {ex}");
}

 

0 Kudos