Operation not allowed

1301
5
10-13-2019 05:14 AM
NadirHussain
Occasional Contributor II

i am writing a webapi.on my devlopment pc  the below code is working fine

Console.WriteLine("Ready with license.");
if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
IPropertySet propertySet = new PropertySet();
propertySet.SetProperty("SERVER", "myServer");
propertySet.SetProperty("INSTANCE", "5151");
propertySet.SetProperty("DATABASE", "SDE");
propertySet.SetProperty("USER", "sa");
propertySet.SetProperty("PASSWORD", "ds");
propertySet.SetProperty("Authentication_mode", "DBMS");
propertySet.SetProperty("VERSION", "SDE.DEFAULT");
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory();
workspace = workspaceFactory.Open(propertySet,0);
return workspace;

and i can perform all opations.

when i publish webapi in production server i am getting this error "operation not allowed."i debug the code 

IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory();

when program reached the above line.

It throws exception "Operation not allowed." i am stuck this line from last three days.I googled it.but could not find any answer.please help me.i will be very thanks full to all.pls pls pls help.

0 Kudos
5 Replies
DuncanHornby
MVP Notable Contributor

Have you seen this page? The modern approach is to use Activator.CreateInstance to create the singleton object.

NadirHussain
Occasional Contributor II

Dear Duncan Hornby,
as per your suggestions i changed the line 
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactory(); from this to 

this line

IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
and debug my program.My debugger pass the suggested line successfully and next line is the below line to open workspace
workspace = workspaceFactory.Open(propertySet, 0);

and on the above line it produces the same error "Operation not allowed."

the code works on development machine but not work on the deployment server.my deployment server operating system is windows server 2016 64 bit and development machine is windows 7 professional 64 bit os.

Please help.

Thanks and regards.

0 Kudos
RonAnkeny
New Contributor III

I am in the midst of converting 10.2.1 code to run against our new 10.6.1 software and I have run into this exact same issue. Did you find the culprit?

0 Kudos
NadirHussain
Occasional Contributor II

sorry for late reply.the below code is working with me on 10.6 and 10.7

private IWorkspace getWorkspace()
{

ESRI.ArcGIS.esriSystem.AoInitialize aoInit = null;
esriLicenseStatus licStatus;
IWorkspace workspace = null;
string status = "";
try
{
Console.WriteLine("Obtaining license");
if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
aoInit = new ESRI.ArcGIS.esriSystem.AoInitialize();
licStatus = aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
if (licStatus == esriLicenseStatus.esriLicenseCheckedOut)
{
Console.WriteLine("Ready with license.");
if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
IPropertySet propertySet = new PropertySet();

propertySet.SetProperty("SERVER", "IP");
propertySet.SetProperty("INSTANCE", "5151");------For  arcsde application server

propertySet.SetProperty("INSTANCE", "sde:sqlserver:sqlservername");------For  direct connect.
propertySet.SetProperty("DATABASE", "database");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "user");
propertySet.SetProperty("Authentication_mode", "DBMS");
propertySet.SetProperty("VERSION", "SDE.DEFAULT");
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
workspace = workspaceFactory.Open(propertySet, 0);
if (workspace != null) {
return workspace;
}

}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
status = ex.Message.ToString()+" "+ex.Source;
}
return workspace;
}

0 Kudos
ksoundaryasubramani
New Contributor

Tried the above Code Still in 10.6.1 I am facing  the same issue. Any other alternatives ?

0 Kudos