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?
Solved! Go to Solution.
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}");
}
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}");
}