arun_kanth

LAYER ADDED FROM SDE DOES NOT DRAW AND ARCMAP CRASHES

Discussion created by arun_kanth on Mar 28, 2012
Dear Friends,
I'm building a stand alone application which opens up an arcmap and ads a bunch of layers (layer files referencing data sets in sde) from local drive.
This application also adds one parcel layer directly from SDE. The application works fine when i'm trying to add  a layer file i mean it adds the layers
and also draws the layers without any issues. But having issues when i'm trying to add the feature class from sde directly.
Apparently it displays the the FeatureClass in the toc contents of the arcmap but does not draw it. I can see the attribute info and the field info too.
But i don't any rendering information i mean when you add a layer onto arcmap and click the +sign next to layer in TOC you would see the as to how the layer would
be rendered right ? But in my case i don't see anything. Also when i right click on the layer i noticed that the "zoomtolayer" functionality is greyed out. Also the arcmap
crashes after a while. It seems like it was trying to draw (as i i see drawing status on the status bar of the arcmap)  for some time and then crashes.

Initially i thought as am not mentioning the rendering info its not drawing and added the rendering info and tried and found no difference.

My Environment:
ARCGIS 10 SP2
DATABASE :SQL SERVER 2008 R2
Language:c#

Here is the code:
#############################################################################################
public IWorkspace CreateArcSdeArcMapWorkspace()
        {
            if (database == String.Empty)
            {
                throw new InvalidOperationException("A database must be specified before building the workspace.");
            }

            // Create an ArcSDE workspace factory.
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
                (factoryType);

            // Create a property set and populate it with connection properties.
            IPropertySet connectionProperties = new PropertySetClass();
            connectionProperties.SetProperty("SERVER", server);
            connectionProperties.SetProperty("DATABASE", database);
            connectionProperties.SetProperty("INSTANCE", instance);
            connectionProperties.SetProperty("USER", user);
            connectionProperties.SetProperty("PASSWORD", password);
            connectionProperties.SetProperty("VERSION", version);

            // Open the geodatabase using the property set.
            IWorkspace workspace = workspaceFactory.Open(connectionProperties, 0);
            return workspace;
        }

IWorkspace analysisWorkspace = workspaceBuilder.CreateArcSdeArcMapWorkspace();
           IFeatureWorkspace featureWorspace = analysisWorkspace as IFeatureWorkspace;
            IFeatureClass inputFeatureClass = featureWorspace.OpenFeatureClass(parcelLayer);


            //IFeatureClass inputFeatureClass = anaWorkspaceHelper.FindFeatureClass(parcelLayer);
            IFeatureLayer featureLayer = new FeatureLayer();
            featureLayer.FeatureClass = inputFeatureClass;

            /*

            IRgbColor fillColor = new RgbColor();
            fillColor.RGB = 100100100;

            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
            pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            pSimpleFillSymbol.Outline.Color = fillColor;

            pSimpleFillSymbol.Color = fillColor;
            pSimpleFillSymbol.Outline.Width = 2.0;

            // set the renderer
            ISimpleRenderer simpleRenderer = new SimpleRendererClass();
            simpleRenderer.Symbol = (ISymbol)pSimpleFillSymbol;

            IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;
            geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer;
            
             */

            ILayer layer = (ILayer)featureLayer;
            layer.Name = featureLayer.FeatureClass.AliasName;

           
            if (layer != null)
            {
                bool validLayer = layer.Valid;
                layer.Visible = false;
                iMap.AddLayer(layer);
                iMapDocument.ActiveView.Refresh();

            }

#####################################################################################

Any help is appreciated !

Outcomes