组件环境:supermap-iobjectsdotnet-9.1.1-16828-70590-all(Bin-x64开发包)
前提:
1.数据源是udbx类型的
问题:
1.数据源没有独占,其它地方没有占用此数据源,超图桌面端程序没有打开;
2.新建新建新的文件型工作空间和新的文件型数据源,组件依然只能打开工作空间,但是读取不到数据源;
1.数据源存放在了工作空间的。
2.源码:
public Frm3DScene(List<Config> configList) { InitializeComponent(); InitalSceneControl(); //创建了一个workspace this.m_workspace = new SuperMap.Data.Workspace(this.components); this.m_configList = configList; if (m_workspace == null) { return; } // this.m_MsdiSuperMap = new ClsMsdiSuperMap(m_workspace, this.mainSceneControl); // this.m_MsdiSuperMap = new ClsMsdiSuperMap(m_workspace, this.mainSceneControl, configList); InitializeScene(); // m_configList = configList; } /// <summary> /// 打开选中工作空间下的场景 /// Open the scene in the workspace /// </summary> private void InitializeScene() { try { if (m_configList[0].Workspace.Trim().Length > 0) { string workspace0 = m_configList[0].Workspace; bool bOpen = OpenWorkSpace(workspace0); if (!bOpen) return; //加载所有场景到m_allSceneNames列表中 m_allSceneNames = new List<String>(); Scenes scenes = m_workspace.Scenes; for (Int32 i = 0; i < scenes.Count; i++) { m_allSceneNames.Add(scenes[i]); } Scene scene = this.mainSceneControl.Scene; scene.Workspace = m_workspace; //TODO:打开第一个场景 bool sceneOpened = scene.Open(m_allSceneNames[0]); if (!sceneOpened) { MessageBox.Show("打开场景失败!"); return; } } } catch (Exception ex) { Trace.WriteLine(ex.Message); } } /// <summary> /// 打开工作空间 /// </summary> /// <returns></returns> private bool OpenWorkSpace(string workspace0) { bool bOpen = false; //TODO:打开数据源 // string path = new DirectoryInfo("../../../../").FullName + @"Data\" + workspace0 + ".smwu"; string path = System.Windows.Forms.Application.StartupPath + @"\Data\" + workspace0 + ".smwu"; WorkspaceConnectionInfo wsConn = null; if (File.Exists(path)) { wsConn = new WorkspaceConnectionInfo(path); wsConn.Type = WorkspaceType.SMWU; } else { //路径不存在的操作 MessageBox.Show("该路径不存在名为" + workspace0 + "的工作空间!", "提示"); } if (wsConn != null) { bOpen = m_workspace.Open(wsConn); } if (!bOpen) { //MessageBox.Show("打开工作空间失败!"); return false; } else { return true; } }