Introduction: Error 1: ArcGIS cannot embed interop types. Solution example: Cannot embed interop type 'ESRI.ArcGIS.Carto.FeatureLayerClass'.
Error 1: ArcGIS cannot embed interop types. Solution example:
Cannot embed interop type 'ESRI.ArcGIS.Carto.FeatureLayerClass'. Use the appropriate interface instead
solve:
1. Expand reference of the current Project;
2. Locate the referenced ESRI.ArcGIS.Carto and right-click -- properties.
3. Change embedded interop type to False
Error 2: ArcGIS version not specified. You must call runtimemanager.bind before create solution example:
1. Open
Program.cs ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop); Put this sentence in Application.SetCompatibleTextRenderingDefault(false); And Application.Run(new Form1()); It should be good between us
2. Add the following line of code at the entry of the system:
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
3. If not, When we migrate our code from ArcGis 9.3 to ArcGis 10 then this type of error occurs. 1.First we add Reference ESRI.ArcGis.ADF.Local
2.Add Reference ESRI.ArcGis.Version
3.Add Line
"ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop); "
prior to call any arcgis object.
4.In all ArcGis Reference property "Specific Version" set to false.
5.Now Go to Project menu of visual studio and there are one option "Add ArcGis License Checking" and Add this file to your project.
Error 3: could not find type or namespace name 'DevComponents' (missing using directive or assembly reference? Workaround example:
Select. Net Framework 3.5 in the properties of the project you will create in VS2010, and it can run without error. It is related to the version.
Error 4: resolve an error like "type exists in ESRI.ArcGIS.AxMapControl.dll and ESRI.ArcGIS.MapControl.dll at the same time"
The key point to solve the problem is that one of the namespaces should be replaced by an alias. The method of alias is as follows. Remember to modify the alias of the assembly dll in the reference
Error 5: mouse over display Feature tip
There are two ways to do this:
The first is achieved by setting the ShowMapTips property of axmapcontrol to true.
The second: through. NET's own control ToolTip!
First code:
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { axMapControl1.ShowMapTips = true; IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer; pFeatureLayer.DisplayField = "Name"; pFeatureLayer.ShowTips = true; }
Second code:
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer; pFeatureLayer.DisplayField = "Name"; pFeatureLayer.ShowTips = true; string pTip; pTip = pFeatureLayer.get_TipText(e.mapX, e.mapY, axMapControl1.ActiveView.FullExtent.Width / 10000); if (pTip != null) { toolTip1.SetToolTip(axMapControl1, "name:" + pTip); } else //When the content displayed in the ToolTip space is null, it will not be displayed! It is equivalent to hiding! { toolTip1.SetToolTip(axMapControl1, ""); } }
The above two methods can display labels, but the second method has a better effect ~!
Error 6: why can't the normal code compile now? What prompt is "can't embed interop types..."
A: Do you use Visual Studio 2010 and C# 4? If so, that's right. This problem has nothing to do with the Engine itself.
This is an improvement of COMInterop in C# 4. The Class suffix of the Class name when creating CoClass can be removed. CoClass itself is not allowed, but the corresponding interface must be used to create objects.
For example,
1. IPoint p = new PointClass()
Replace with:
1. IPoint p = new Point()
Error 7: why does the previously normal code report an error as soon as it runs and throw an exception BadImageFormatException
Your operating system is 64 bit Windows, right? But ArcGIS now has only 32-bit, so you must use X86 platform to generate projects.
Open the project properties, find the target platform in the "generate" tab, change Any CPU to x86 and regenerate.
Error 8: add toolbox item, find dll of Engine
This question should be more specific:
1. Right click in the VS toolbox, add a tab, and name it ArcGIS Windows Form
2. Right click on the new tab and select item
3. Click Browse to find ESRI.ArcGIS.AxControls.dll (installed in "C:\Program Files\ArcGIS\DotNet\ESRI.ArcGIS.AxControls.dll" by default) and open it.
4. Check the new ArcGIS controls and click OK.
Error 9: SceneControl scroll wheel scaling (C#)
First, add axSceneControl control and linece control, and add ArcScene data to the control.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using ESRI.ArcGIS.Analyst3D; using ESRI.ArcGIS.Geometry; namespace wheel1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.MouseWheel += new System.Windows.Forms.MouseEventHandler (this.axSceneControl1_Wheel); } private void Form1_Load(object sender, EventArgs e) { } private void axSceneControl1_Wheel(object sender, System.Windows.Forms.MouseEventArgs e) { try { System.Drawing.Point pSceLoc = axSceneControl1.PointToScreen (this.axSceneControl1.Location); System.Drawing.Point Pt = this.PointToScreen(e.Location); if (Pt.X < pSceLoc.X | Pt.X > pSceLoc.X + axSceneControl1.Width | Pt.Y < pSceLoc.Y | Pt.Y > pSceLoc.Y + axSceneControl1.Height) return; double scale = 0.2; if (e.Delta < 0) scale = -0.2; ICamera pCamera = axSceneControl1.Camera; IPoint pPtObs = pCamera.Observer; IPoint pPtTar = pCamera.Target; pPtObs.X += (pPtObs.X - pPtTar.X) * scale; pPtObs.Y += (pPtObs.Y - pPtTar.Y) * scale; pPtObs.Z += (pPtObs.Z - pPtTar.Z) * scale; pCamera.Observer = pPtObs; axSceneControl1.SceneGraph.RefreshViewers(); } catch (Exception ex) { } } } }
Error 10: car walking along the specified line in SceneControl (C#)
ILayer layer = axSceneControl1.SceneGraph.Scene.get_Layer(5); IFeatureLayer featurelayer = (IFeatureLayer)layer; IFeatureClass featureclass = featurelayer.FeatureClass; IFeature feature = featureclass.GetFeature(0); IPolyline polyline = (IPolyline )feature.Shape; double d = polyline.Length; IPoint point1 = new PointClass(); IPoint point2 = new PointClass(); for (int i = 2; i <= (int)d;i++ ) { polyline.QueryPoint(esriSegmentExtension.esriNoExtension, i, false, point1); polyline.QueryPoint(esriSegmentExtension.esriExtendAtFrom , i-150, false, point2); point2 .Z =13; point2.X= point2.X +-50; ICamera camera = axSceneControl1.SceneViewer.Camera; IPoint point3=new PointClass (); point3.X = point1.X; point3.Y = point1.Y; point3.Z =13; camera.Target = point3; camera.Observer = point2; IScene pscene = axSceneControl1.SceneGraph.Scene; IMarker3DSymbol pmark3dsymbol = new Marker3DSymbolClass(); pmark3dsymbol.CreateFromFile("E:\\3dmax\\automobile.3DS"); IMarkerSymbol marksy = (IMarkerSymbol)pmark3dsymbol; marksy.Size = 20; marksy.Angle = 90; IElement pelement = new MarkerElementClass(); IMarkerElement pmarkelement = (IMarkerElement)pelement; pmarkelement.Symbol = (IMarkerSymbol)marksy; pelement.Geometry = point1; IGraphicsLayer player = axSceneControl1.SceneGraph.Scene.BasicGraphicsLayer; IGraphicsContainer3D pgraphiccontainer3d = (IGraphicsContainer3D)player; pgraphiccontainer3d.DeleteAllElements(); pgraphiccontainer3d.AddElement((IElement)pmarkelement); axSceneControl1.SceneGraph.RefreshViewers(); }
Error 11: write text on the map under Engine
void DrawTextToMap(string text, ESRI.ArcGIS.Geometry.Point point2) { //Create font object ITextSymbol textSymbol = new TextSymbol(); //Create system fonts System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 32, System.Drawing.FontStyle.Regular); //Font conversion // textSymbol.Font = (stdole.IFontDisp)ESRI.ArcGIS.Utility.COMSupport.OLE.GetIFontDispFromFont(drawFont); textSymbol.Font = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(drawFont); textSymbol.Color = GetRGBColor(0, 0, 0); //Create font path ITextPath textPath = new BezierTextPath(); //to spline the text //Grab hold of the ISimpleTextSymbol interface through the ITextSymbol interface ISimpleTextSymbol simpleTextSymbol = (ISimpleTextSymbol)textSymbol; //Set the text path of the simple text symbol simpleTextSymbol.TextPath = textPath; IPoint m_point=new ESRI.ArcGIS.Geometry.Point(); // double xx = point2.X; m_point.X = point2.X; m_point.Y = point2.Y; //Output font object oTextSymbol = textSymbol; object opointSymbol = m_point; mapControl.DrawText(m_point, text, ref oTextSymbol); } private IRgbColor GetRGBColor(int red, int green, int blue) { //Create rgb color and grab hold of the IRGBColor interface IRgbColor rGB = new RgbColor(); //Set rgb color properties rGB.Red = red; rGB.Green = green; rGB.Blue = blue; rGB.UseWindowsDithering = true; return rGB; }
Error 12: how to enlarge the query feature to a certain scale after the query is highlighted
First, determine whether your layer has the MinimumScale attribute set. If so, remove the attribute;
Then, use the controlszomtoselectedcommandclass interface, and the code is as follows:
You can zoom to the selected featureICommand pCommand = new ControlsZoomToSelectedCommandClass(); pCommand.OnCreate(axMapControl1.Object); pCommand.OnClick();
#region is a small function to find graphic features through attributes in the attribute table private void dataGridView1_SelectionChanged(object sender, EventArgs e) { DataGridViewSelectedRowCollection SelRows = this.dataGridView1.SelectedRows; DataGridViewRow row; RibbonForm1 form = (RibbonForm1)Application.OpenForms[0]; IMap m = form.getMapControl().Map; m.ClearSelection(); for (int i = 0; i < SelRows.Count; i++) { row = SelRows[i]; int ID = Convert.ToInt32(row.Cells["OBJECTID"].Value.ToString()); IFeatureLayer flyr = (IFeatureLayer)layer; IFeatureClass featurecls = flyr.FeatureClass; IFeature feature = featurecls.GetFeature(ID); m.SelectFeature(layer, feature);//Get the graphic features corresponding to the selected row in the attribute table } //form.getMapControl().Refresh(); //Zoom in to a certain scale to display the selected features ICommand pCommand = new ControlsZoomToSelectedCommandClass(); //pCommand.OnCreate(axMapControl1.Object); pCommand.OnCreate(form.getMapControl().Object); pCommand.OnClick(); } #endregion
Error 13: two ways to export a map as a picture
In the development of ArcGIS, we often need to print (or transfer out) the current Map To the image file. There are two methods to transfer the image from the Map or Layout. One is through the OutPut function of IActiveView, and the other is through the IExport interface. The first method is fast and easy to implement. However, when the number of rows or columns of the image exceeds about 10000, the export often fails (the specific reason is unknown) , the second method is slow to export, but the effect is good, and you can abort the export operation through ITrackCancel during the export process.
Export through IActiveView is realized by creating Graphics objects. The specific example code is as follows:
/// <summary> ///Output the content within the specified range (the range is the rule area) on the Map to the Image. Note that when the number of rows or columns of the picture exceeds about 10000, the failure of cause indication occurs /// </summary> ///< param name = "PMAP" > map to be transferred out < / param > ///< param name = "outrect" > output picture size < / param > ///< param name = "penevelope" > specified output range (Envelope type) < / param > ///< returns > what format does the output Image need to be saved? You can implement < / returns > through the Image object public static Image SaveCurrentToImage(IMap pMap, Size outRect, IEnvelope pEnvelope) { //assignment tagRECT rect = new tagRECT(); rect.left = rect.top = 0; rect.right = outRect.Width; rect.bottom = outRect.Height; try { //Convert to activeView. If it is ILayout, convert Layout to IActiveView IActiveView pActiveView = (IActiveView)pMap; // Create an image in 24 bit color Image image = new Bitmap(outRect.Width, outRect.Height); //, System.Drawing.Imaging.PixelFormat.Format24bppRgb); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image); // Fill background color (white) g.FillRectangle(Brushes.White, 0, 0, outRect.Width, outRect.Height); int dpi = (int)(outRect.Width / pEnvelope.Width); pActiveView.Output(g.GetHdc().ToInt32(), dpi, ref rect, pEnvelope, null); g.ReleaseHdc(); return image; } catch (Exception excp) { MessageBox.Show(excp.Message + "There is an error transferring the current map out. The reason is unknown", "Error prompt", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } } adopt IExport The export of interface implementation also needs to pass the IActiveView of OutPut , but its roll out handle is IExport of StartExporting Function returns DC,The specific example code is as follows: //Outputs the current map to the specified file public void ExportMapExtent(IActiveView pView, Size outRect,string outPath) { try { //Parameter check if pView == null ) { throw new Exception("Input parameter error,Unable to generate picture file!"); } //Different types of objects are generated according to the given file extension ESRI.ArcGIS.Output.IExport export = null; if (outPath.EndsWith(".jpg")) { export = new ESRI.ArcGIS.Output.ExportJPEGClass(); } else if (outPath.EndsWith(".tiff")) { export = new ESRI.ArcGIS.Output.ExportTIFFClass(); } else if (outPath.EndsWith(".bmp")) { export = new ESRI.ArcGIS.Output.ExportBMPClass(); } else if (outPath.EndsWith(".emf")) { export = new ESRI.ArcGIS.Output.ExportEMFClass(); } else if (outPath.EndsWith(".png")) { export = new ESRI.ArcGIS.Output.ExportPNGClass(); } else if (outPath.EndsWith(".gif")) { export = new ESRI.ArcGIS.Output.ExportGIFClass(); } export.ExportFileName = outPath; IEnvelope pEnvelope = pView.Extent; //Export parameters export.Resolution = 300; tagRECT exportRect = new tagRECT(); exportRect.left = exportRect.top = 0; exportRect.right = outRect.Width; exportRect.bottom = (int)(exportRect.right * pEnvelope.Height / pEnvelope.Width); ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass(); //Output range envelope.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom); export.PixelBounds = envelope; //Can be used to cancel the operation ITrackCancel pCancel = new CancelTrackerClass(); export.TrackCancel = pCancel; pCancel.Reset(); //When the ESC key is clicked, the transfer out is aborted pCancel.CancelOnKeyPress = true; pCancel.CancelOnClick = false; pCancel.ProcessMessages = true; //Get handle System.Int32 hDC = export.StartExporting(); //Start transferring out pView.Output(hDC, (System.Int16)export.Resolution, ref exportRect, pEnvelope, pCancel); bool bContinue = pCancel.Continue(); //Capture continue if (bContinue) { export.FinishExporting(); export.Cleanup(); } else { export.Cleanup(); } bContinue = pCancel.Continue(); } catch (Exception excep) { //Error message prompt } }
Error 14: ArcEngine shortest path analysis
using System; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.NetworkAnalysis; namespace GisEditor { /// <summary> ///Shortest path analysis /// </summary> public class ClsPathFinder { private IGeometricNetwork m_ipGeometricNetwork; private IMap m_ipMap; private IPointCollection m_ipPoints; private IPointToEID m_ipPointToEID; private double m_dblPathCost =0; private IEnumNetEID m_ipEnumNetEID_Junctions; private IEnumNetEID m_ipEnumNetEID_Edges; private IPolyline m_ipPolyline; #region Public Function //Returns and sets the current map public IMap SetOrGetMap { set{ m_ipMap = value;} get{return m_ipMap;} } //Open the network workspace for the geometry dataset public void OpenFeatureDatasetNetwork(IFeatureDataset FeatureDataset) { CloseWorkspace(); if (!InitializeNetworkAndMap(FeatureDataset)) Console.WriteLine( "open network error"); } //Collection of input points public IPointCollection StopPoints { set{m_ipPoints= value;} get{return m_ipPoints;} } //Path cost public double PathCost { get {return m_dblPathCost;} } //Returns the geometry of the path public IPolyline PathPolyLine() { IEIDInfo ipEIDInfo; IGeometry ipGeometry; if(m_ipPolyline!=null)return m_ipPolyline; m_ipPolyline = new PolylineClass(); IGeometryCollection ipNewGeometryColl = m_ipPolyline as IGeometryCollection; ISpatialReference ipSpatialReference = m_ipMap.SpatialReference; IEIDHelper ipEIDHelper = new EIDHelperClass(); ipEIDHelper.GeometricNetwork = m_ipGeometricNetwork; ipEIDHelper.OutputSpatialReference = ipSpatialReference; ipEIDHelper.ReturnGeometries = true; IEnumEIDInfo ipEnumEIDInfo = ipEIDHelper.CreateEnumEIDInfo(m_ipEnumNetEID_Edges); int count = ipEnumEIDInfo.Count; ipEnumEIDInfo.Reset(); for(int i =0;i<count;i++) { ipEIDInfo = ipEnumEIDInfo.Next(); ipGeometry = ipEIDInfo.Geometry; ipNewGeometryColl.AddGeometryCollection( ipGeometry as IGeometryCollection); } return m_ipPolyline; } //Solution path public void SolvePath(string WeightName) { try { int intEdgeUserClassID; int intEdgeUserID; int intEdgeUserSubID; int intEdgeID; IPoint ipFoundEdgePoint; double dblEdgePercent; ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN; INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver; INetwork ipNetwork = m_ipGeometricNetwork.Network; ipNetSolver.SourceNetwork = ipNetwork; INetElements ipNetElements = ipNetwork as INetElements; int intCount = m_ipPoints.PointCount; //Define an array of border flags IEdgeFlag[] pEdgeFlagList = new EdgeFlagClass[intCount]; for(int i = 0;i<intCount ;i++) { INetFlag ipNetFlag = new EdgeFlagClass()as INetFlag; IPoint ipEdgePoint = m_ipPoints.get_Point(i); //Find the nearest edge of the input point m_ipPointToEID.GetNearestEdge(ipEdgePoint, out intEdgeID,out ipFoundEdgePoint, out dblEdgePercent); ipNetElements.QueryIDs( intEdgeID, esriElementType.esriETEdge, out intEdgeUserClassID, out intEdgeUserID,out intEdgeUserSubID); ipNetFlag.UserClassID = intEdgeUserClassID; ipNetFlag.UserID = intEdgeUserID; ipNetFlag.UserSubID = intEdgeUserSubID; IEdgeFlag pTemp = (IEdgeFlag)(ipNetFlag as IEdgeFlag); pEdgeFlagList[i]=pTemp; } ipTraceFlowSolver.PutEdgeOrigins(ref pEdgeFlagList); INetSchema ipNetSchema = ipNetwork as INetSchema; INetWeight ipNetWeight = ipNetSchema.get_WeightByName(WeightName); INetSolverWeights ipNetSolverWeights = ipTraceFlowSolver as INetSolverWeights; ipNetSolverWeights.FromToEdgeWeight = ipNetWeight;//Start edge weight ipNetSolverWeights.ToFromEdgeWeight = ipNetWeight;//Weight of termination edge object [] vaRes =new object[intCount-1]; //Get the set of sidelines and intersections through findpath ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinSum, out m_ipEnumNetEID_Junctions,out m_ipEnumNetEID_Edges, intCount-1, ref vaRes); //Calculate element cost m_dblPathCost = 0; for (int i =0;i<vaRes.Length;i++) { double m_Va =(double) vaRes[i]; m_dblPathCost = m_dblPathCost + m_Va; } m_ipPolyline = null; } catch(Exception ex) { Console.WriteLine(ex.Message); } } #endregion #region Private Function //Initialize geometric networks and maps private bool InitializeNetworkAndMap(IFeatureDataset FeatureDataset) { IFeatureClassContainer ipFeatureClassContainer; IFeatureClass ipFeatureClass ; IGeoDataset ipGeoDataset; ILayer ipLayer ; IFeatureLayer ipFeatureLayer; IEnvelope ipEnvelope, ipMaxEnvelope ; double dblSearchTol; INetworkCollection ipNetworkCollection = FeatureDataset as INetworkCollection; int count = ipNetworkCollection.GeometricNetworkCount; //Get the first geometric network workspace m_ipGeometricNetwork = ipNetworkCollection.get_GeometricNetwork(0); INetwork ipNetwork = m_ipGeometricNetwork.Network; if(m_ipMap!=null) { m_ipMap = new MapClass(); ipFeatureClassContainer = m_ipGeometricNetwork as IFeatureClassContainer; count = ipFeatureClassContainer.ClassCount; for(int i =0;i<count;i++) { ipFeatureClass = ipFeatureClassContainer.get_Class(i); ipFeatureLayer = new FeatureLayerClass(); ipFeatureLayer.FeatureClass = ipFeatureClass; m_ipMap.AddLayer( ipFeatureLayer); } } count = m_ipMap.LayerCount; ipMaxEnvelope = new EnvelopeClass(); for(int i =0;i<count;i++) { ipLayer = m_ipMap.get_Layer(i); ipFeatureLayer = ipLayer as IFeatureLayer; ipGeoDataset = ipFeatureLayer as IGeoDataset; ipEnvelope = ipGeoDataset.Extent; ipMaxEnvelope.Union( ipEnvelope); } m_ipPointToEID = new PointToEIDClass(); m_ipPointToEID.SourceMap = m_ipMap; m_ipPointToEID.GeometricNetwork = m_ipGeometricNetwork; double dblWidth = ipMaxEnvelope.Width; double dblHeight = ipMaxEnvelope.Height; if( dblWidth > dblHeight) dblSearchTol = dblWidth / 100; else dblSearchTol = dblHeight / 100; m_ipPointToEID.SnapTolerance = dblSearchTol; return true ; } //Close workspace private void CloseWorkspace() { m_ipGeometricNetwork = null; m_ipPoints = null; m_ipPointToEID = null; m_ipEnumNetEID_Junctions = null; m_ipEnumNetEID_Edges = null; m_ipPolyline = null; } #endregion } } remarks: The order in which the class is called: ClsPathFinder m_ipPathFinder; if(m_ipPathFinder==null)//Open geometric network workspace { m_ipPathFinder = new ClsPathFinder(); ipMap = this.m_ActiveView.FocusMap; ipLayer = ipMap.get_Layer(0); ipFeatureLayer = ipLayer as IFeatureLayer; ipFDB = ipFeatureLayer.FeatureClass.FeatureDataset; m_ipPathFinder.SetOrGetMap = ipMap; m_ipPathFinder.OpenFeatureDatasetNetwork(ipFDB); } private void ViewMap_OnMouseDown(object sender, ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEvent e)//Gets the point entered with the mouse on the map { IPoint ipNew ; if( m_ipPoints==null) { m_ipPoints = new MultipointClass(); m_ipPathFinder.StopPoints = m_ipPoints; } ipNew = ViewMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x,e.y); object o = Type.Missing; m_ipPoints.AddPoint(ipNew,ref o,ref o); } m_ipPathFinder.SolvePath("Weight");//Resolve path first IPolyline ipPolyResult = m_ipPathFinder.PathPolyLine();//Finally, the shortest path is returned
error 15: Unable to copy the file "obj\x86\Debug\codeprocess.exe" to "bin\Debug\codeprocess.exe". The file "bin\Debug\codeprocess.exe" is being used by another process, so the process cannot access this file.
Error 16: an error occurs when ArcEngine opens shapefile HRESULT:0x80040258
private IFeatureClass OpenShp(string pTableName, string pShpPath)
{
try
{
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
IWorkspace pWorkspace =pWorkspaceFactory.OpenFromFile(pShpPath,0);
IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pTableName);
return pFeatureClass;
}
catch (Exception ex)
{
return null;
}
}
When I got to the red letter line, I reported an error. Later, I learned that it was not the code problem, but the parameters brought in were wrong
pShpPath Just the path name, such as C:\AAA
Is not the full path name of the file
I brought in C:\AAA\BBB.shp, so I made an error
Originally, when arcengine developed shapefile s, it opened a folder as a workspace, and each shape file in the folder corresponds to a feature class
Copyright notice: the content of this article is spontaneously contributed by Alibaba cloud real name registered users. The copyright belongs to the original author. Alibaba cloud developer community does not own its copyright or bear corresponding legal liabilities. Please check the specific rules< Alicloud developer community user service agreement >And< Alibaba cloud developer community intellectual property protection guidelines >. If you find any content suspected of plagiarism in this community, please fill in Infringement complaint form Report, once verified, the community will immediately delete the suspected infringement content.