locked
can not add shape to shapeFile and get ' threw an exception of type 'System.AccessViolationException' RRS feed

  • Question

  • hi,
    I use mapwingis.ocx to work with shapefiles. I want to add a shape to a shapefile as below:

    MapWinGIS.

    Shapefile shapefile = new Shapefile();bool b = shapefile.CreateNew(Path.Combine(@"c:\", "shpFilePGAStations.shp"), MapWinGIS.ShpfileType.SHP_POINT);
    MapWinGIS.
    Field field = new Field() { };field.Name = "latitude";field.Type = MapWinGIS.FieldType.DOUBLE_FIELD;field.Width = 100;

     

    icallback icallback = new icallback();

     

    int index = 0;

    //Important lines
    Shape shape = new Shape()
    shape.Create(ShpfileType.SHP_POINT);
    shape.GlobalCallback = icallback;
    shapefile.EditInsertShape(shape, ref index);
    hapefile.StopEditingShapes(
    true, true, icallback);

    after i add shape to shapeFile , when i want to see it's properties value , debugger shows:
    ' threw an exception of type 'System.AccessViolationException' and didn't add shape to shapefile.
    it's properties get error when it wants to add to the shapeFile.
    how can i fix it?
    i read it's manual but doesn't help me. I hope u can

    • Moved by Bin-ze Zhao Monday, May 25, 2009 3:05 AM third party (From:Visual C# General)
    Wednesday, May 20, 2009 1:54 PM

Answers

  • it's because of third party's Dll and not related to me!
    i download another dll and the bug fixed
    • Marked as answer by m-q Thursday, September 10, 2009 8:49 AM
    Thursday, September 10, 2009 8:49 AM

All replies

  • Could you check if the shapefile is read only?
    Abhishek Shukla MCP WPF
    Wednesday, May 20, 2009 2:22 PM
  • thanks abheshek, the shapefile is not readonly
    a wait your new answer
    Friday, May 22, 2009 5:59 AM
  • Hello,

    I don't think ShapeFile class is from Microsoft.  So if it's from third party I am afraid we can't support this as it is against company rules.

    I am sorry to state this, however if you have any related questions please feel free to post here.

    Thanks
    Binze
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, May 22, 2009 8:20 AM
  • it's because of third party's Dll and not related to me!
    i download another dll and the bug fixed
    • Marked as answer by m-q Thursday, September 10, 2009 8:49 AM
    Thursday, September 10, 2009 8:49 AM