Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I develop desktop standalone application and use this code to open Network Dataset, but it fails with HRESULT on datasetContainer3.get_DatasetByName().

public static ESRI.ArcGIS.Geodatabase.INetworkDataset OpenNetworkDataset1(ESRI.ArcGIS.Geodatabase.IWorkspace networkDatasetWorkspace, System.String networkDatasetName, System.String featureDatasetName)
    {
        if (networkDatasetWorkspace == null || networkDatasetName == "" || featureDatasetName == null)
        {
            return null;
        }

        ESRI.ArcGIS.Geodatabase.IDatasetContainer3 datasetContainer3 = null;
        switch (networkDatasetWorkspace.Type)
        {
            case ESRI.ArcGIS.Geodatabase.esriWorkspaceType.esriFileSystemWorkspace:

                // Shapefile or SDC network dataset workspace
                ESRI.ArcGIS.Geodatabase.IWorkspaceExtensionManager workspaceExtensionManager = networkDatasetWorkspace as ESRI.ArcGIS.Geodatabase.IWorkspaceExtensionManager; // Dynamic Cast
                ESRI.ArcGIS.esriSystem.UID networkID = new ESRI.ArcGIS.esriSystem.UIDClass();

                networkID.Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension";
                ESRI.ArcGIS.Geodatabase.IWorkspaceExtension workspaceExtension = workspaceExtensionManager.FindExtension(networkID);
                datasetContainer3 = workspaceExtension as ESRI.ArcGIS.Geodatabase.IDatasetContainer3; // Dynamic Cast
                break;

            case ESRI.ArcGIS.Geodatabase.esriWorkspaceType.esriLocalDatabaseWorkspace:

            // Personal Geodatabase or File Geodatabase network dataset workspace

            case ESRI.ArcGIS.Geodatabase.esriWorkspaceType.esriRemoteDatabaseWorkspace:

                // SDE Geodatabase network dataset workspace
                ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = networkDatasetWorkspace as ESRI.ArcGIS.Geodatabase.IFeatureWorkspace; // Dynamic Cast
                ESRI.ArcGIS.Geodatabase.IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset(featureDatasetName);
                ESRI.ArcGIS.Geodatabase.IFeatureDatasetExtensionContainer featureDatasetExtensionContainer = featureDataset as ESRI.ArcGIS.Geodatabase.IFeatureDatasetExtensionContainer; // Dynamic Cast
                ESRI.ArcGIS.Geodatabase.IFeatureDatasetExtension featureDatasetExtension = featureDatasetExtensionContainer.FindExtension(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTNetworkDataset);
                datasetContainer3 = featureDatasetExtension as ESRI.ArcGIS.Geodatabase.IDatasetContainer3; // Dynamic Cast
                break;
        }

        if (datasetContainer3 == null)
            return null;

        ESRI.ArcGIS.Geodatabase.IDataset dataset = datasetContainer3.get_DatasetByName(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTNetworkDataset, networkDatasetName);

        return dataset as ESRI.ArcGIS.Geodatabase.INetworkDataset; // Dynamic Cast
    }

What am I doing wrong?

share|improve this question
    
Problem is "solved". Seems like I faced a bug: there were some russian symbols in feature class (source for network) name. I created same dataset and source featureclass with only english letters in name, then created network dataset. My code works fine with this network dataset. –  Ilya Solovyev Mar 27 '12 at 9:27
1  
So does anyone know what the real issue here is? No/broken Unicode support? –  blah238 Mar 28 '12 at 0:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.