Opening .sde connection file

2326
3
Jump to solution
10-31-2012 09:23 AM
Highlighted
New Contributor III
I'm getting Error HRESULT E_FAIL has been returned from a call to a COM component, when I run my ArcMap addin. But the same code works perfectly in debug mode.

The error comes from where it's trying to open an sde connection file. Any idea why this is happening?

        private IFeatureLayer GetLayer(IMap pMap, String layerName)         {             IWorkspaceFactory pWorkspaceFactory = new SdeWorkspaceFactory();             IWorkspace workspace;                           if (layerName == "wwShedMinor")             {                 workspace = pWorkspaceFactory.OpenFromFile("\\\\fileserver1\\1Rb.sde", 0);             }             else             {                 workspace = pWorkspaceFactory.OpenFromFile("\\\\fileserver1\\\\1b", 0);             }              IPropertySet propSet = workspace.ConnectionProperties;              IFeatureWorkspace pWorkspace = pWorkspaceFactory.Open(propSet, 0) as IFeatureWorkspace;             IFeatureClass featureClass = pWorkspace.OpenFeatureClass(layerName);              IFeatureLayer featureLayer = new FeatureLayer();             featureLayer.FeatureClass = featureClass;             featureLayer.Name = layerName;             //pMap.AddLayer(featureLayer);              return featureLayer;         }
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Regular Contributor II
Sounds like an SDE problem.  When you make a selection or cursor with few elements, everything is done in memory.  Beyond a threshold, around 300, the selection is done in SDE tables.  The SDE forums has more information about it.  I usually just corner our DBA till he fixes it.

View solution in original post

Reply
0 Kudos
3 Replies
Highlighted
Regular Contributor II
Looks like you are trying to open the workspace twice.  Open from file with the sde connection opens the workspace, there is no need to retrieve the property set to try to open it again, it will just return the same workspace.

Running in debug you may be using a different user (run as...) which has access to the network resource where the sde file is located.  You may also have sharing problems with multiple users accessing the same sde file...  You may want to check if the file exists and its' properties through standard .net methods before trying to open it.
Reply
0 Kudos
Highlighted
New Contributor III
Just noticed that it runs fine when the number of records being updated is less than 300... Very strange! I can't connect the dots.

What the code is doing is to grab the attribute in the sewershed polygon intersect with a point feature class, and write in the attribute of the point feature class with the sewershed information. Now if the points are less than 300, everything goes fine; if not, ArcMap tells me that it has trouble opening the connection file for the sewershed layer.
Reply
0 Kudos
Highlighted
Regular Contributor II
Sounds like an SDE problem.  When you make a selection or cursor with few elements, everything is done in memory.  Beyond a threshold, around 300, the selection is done in SDE tables.  The SDE forums has more information about it.  I usually just corner our DBA till he fixes it.

View solution in original post

Reply
0 Kudos