Error opening a connection with IWorkspaceFactory in a SOE

453
5
11-30-2023 08:06 AM
Labels (1)
mariopetta
New Contributor II

Hi,

I'm developing a SOE to open a connection to a specific workspace using IWorkspaceFactory. I'm using a PostgreSQL geodatabase. Below is my code:

IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory"));
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("SERVER", "vmsql201764.nco.inet");
propertySet.SetProperty("INSTANCE", "vmsql201764.nco.inet");
propertySet.SetProperty("DATABASE", "sde");
propertySet.SetProperty("USER", "sde");
propertySet.SetProperty("PASSWORD", sdePassword);
propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS");
propertySet.SetProperty("VERSION", versionName);

IWorkspace workspace = workspaceFactory.Open(propertySet, 0);

It throws an Exception with message: "This operation is not allowed". 

Any idea? Thank you.

Regards,

Mario Petta

 

0 Kudos
5 Replies
MarceloMarques
Esri Regular Contributor

propertySet.SetProperty("VERSION", versionName);

the version name must be SDE.DEFAULT or a child version of SDE.

you can create a geodatabase connection file with the same parameters in ArcGIS Pro to test the connection to the geodatabase.

| Marcelo Marques | Principal Product Engineer | Esri |
| Cloud & Database Administrator | OCP - Oracle Certified Professional |
I work with Enterprise Geodatabases since 1997.
“ I do not fear computers. I fear the lack of them." Isaac Isimov
0 Kudos
mariopetta
New Contributor II

I'm trying both with the SDE.DEFAULT version and with a child version of sde, but the error persists.

I will try using a connection file with the same parameters, to ensure all is ok with the connection to DB.

0 Kudos
mariopetta
New Contributor II

Creating a geodatabase connection file in ArcGIS Pro with the same parameters works, but the code above throws an Exception. Any other suggestion?

MP

0 Kudos
mariopetta
New Contributor II

As a workaround, I created a geodatabase connection file on the server, through ArcGIS Pro. Then, in the SOE source code I opened an IWorkspace with IWorkspaceFactory.OpenFromFile and it worked.

0 Kudos
MarceloMarques
Esri Regular Contributor

Glad is working now.

| Marcelo Marques | Principal Product Engineer | Esri |
| Cloud & Database Administrator | OCP - Oracle Certified Professional |
I work with Enterprise Geodatabases since 1997.
“ I do not fear computers. I fear the lack of them." Isaac Isimov
0 Kudos