Select to view content in your preferred language

Error opening a connection with IWorkspaceFactory in a SOE

767
5
11-30-2023 08:06 AM
Labels (1)
mariopetta
Emerging Contributor

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 | Esri Principal Product Engineer | Cloud & Database Administrator | OCP - Oracle Certified Professional | "In 1992, I embarked on my journey with Esri Technology, and since 1997, I have been working with ArcSDE Geodatabases, right from its initial release. Over the past 32 years, my passion for GIS has only grown stronger." | “ I do not fear computers. I fear the lack of them." Isaac Isimov |
0 Kudos
mariopetta
Emerging Contributor

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
Emerging Contributor

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
Emerging Contributor

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 | Esri Principal Product Engineer | Cloud & Database Administrator | OCP - Oracle Certified Professional | "In 1992, I embarked on my journey with Esri Technology, and since 1997, I have been working with ArcSDE Geodatabases, right from its initial release. Over the past 32 years, my passion for GIS has only grown stronger." | “ I do not fear computers. I fear the lack of them." Isaac Isimov |
0 Kudos