问题描述
OpenFileDialogdlgOpen=newOpenFileDialog();dlgOpen.Title="选择影像数据";dlgOpen.Filter="tif影像(.tif)|*.tif|jpg影像(.jpg)|*.jpg|bmp影像(.bmp)|*.bmp|所有影像(*.*)|*.*";dlgOpen.Multiselect=false;if(dlgOpen.ShowDialog()!=DialogResult.OK){return;}try{pPath=dlgOpen.FileName;this.txtDmpPath.Text=pPath.ToString();this.btnAdd.Enabled=true;this.dxErrorProvider1.ClearErrors();}catch(System.Exceptionex){AppLog.log.Error(ex);this.dxErrorProvider1.SetError(this.btnSelectDmp,"非法的影像数据!");}上面的没问题intindex=pPath.LastIndexOf("\");stringfilePath=pPath.Substring(0,index);stringfileNam=pPath.Substring(index+1);IWorkspaceFactoryworkspcFac=newRasterWorkspaceFactoryClass();IRasterWorkspacerasterWorkspc;IRasterDatasetrasterDatst=newRasterDatasetClass();IRasterLayerrasterLay=newRasterLayerClass();rasterWorkspc=workspcFac.OpenFromFile(filePath,0)asIRasterWorkspace;rasterDatst=(IRasterDataset)rasterWorkspc.OpenRasterDataset(fileNam);rasterLay.CreateFromDataset(rasterDatst);m_App.AxMapControl.AddLayer(rasterLay);m_App.AxMapControl.Refresh();红色的地方出现异常请大家帮忙看看DataFrameExtent=“rasterLay.DataFrameExtent”引发了“System.Runtime.InteropServices.COMException”类型的异常FilePath=“rasterLay.FilePath”引发了“System.Runtime.InteropServices.COMException”类型的异常Renderer=“rasterLay.Renderer”引发了“System.Runtime.InteropServices.COMException”类型的异常
解决方案
解决方案二:
没人会吗。。。。。。
解决方案三:
m_App.AxMapControl.AddLayer(rasterLayasILayer);