AnsweredAssumed Answered

Opening .sde connection file

Question asked by Yiman on Oct 31, 2012
Latest reply on Nov 2, 2012 by agray1
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;         }