Shapefile.Open exclusive lock bug?

Topics: Data Access, SharpMap v2.0
May 27, 2008 at 8:36 PM
I need to have SharpMap not lock my shapefile. But it doesn't seem to work for me.

I have code like

            shapefilePath = @"C:\temp\my_shapefile.shp";

            SharpMap.Data.Providers.ShapeFile.ShapeFileProvider shapefileProvider = new SharpMap.Data.Providers.ShapeFile.ShapeFileProvider(shapefilePath);
            SharpMap.Data.Providers.ShapeFile.ShapeFileProvider shapefileProvider2 = new SharpMap.Data.Providers.ShapeFile.ShapeFileProvider(shapefilePath);
            shapefileProvider.Open(false); // false should mean "don't lock me"
            shapefileProvider2.Open(false); // Errors here

Is this just broken? I get exception
+        ex    {"The process cannot access the file 'C:\\temp\\my_shapefile.shp' because it is being used by another process."}    System.Exception {System.IO.IOException}

Unfortunately I haven't got the source compiling, just using binaries...any ideas?

Coordinator
May 27, 2008 at 9:45 PM
Hi ppenn -

We were just talking about this on IRC last week. I think John Diss checked in some changes to the v1.1 experiemental branch which I haven't gotten to port over to the v2.0 branch which resolves this. As I've gotten to another milestone this week, I hope to clean up the sources so that check-out/build/run on the v2.0 sources is a lot more repeatable, and then you could just add the lines yourself.
May 27, 2008 at 10:28 PM
Thanks -- I managed to get the right source, couldn't get the latest stuff to compile for a while, then did and realized everything's changed(!). Fun times.

Anyway, I got the 2.0 beta 1 (http://sharpmapv2.googlecode.com/svn/tags/Beta1/) and that compiles first time (yay!), so I can see where it's ignoring the exclusive lock. There were some commented-out routines (enableReading) that helped point the way.

So I can stick with my local copy until the next beta/rc comes out (when is that slated for?).


Phil  

codekaizen wrote:
Hi ppenn -

We were just talking about this on IRC last week. I think John Diss checked in some changes to the v1.1 experiemental branch which I haven't gotten to port over to the v2.0 branch which resolves this. As I've gotten to another milestone this week, I hope to clean up the sources so that check-out/build/run on the v2.0 sources is a lot more repeatable, and then you could just add the lines yourself.


Apr 2, 2010 at 3:51 PM

Hi CodeKaizen,

I am getting the same error when using the shapefile provider for the Wms demo project......... It says the "The process cannot access the file 'C:\\temp\\my_shapefile.shp' because it is being used by another process."

I added the enable reading method from the Beta Project but it still gives the same error.

Do lemme know if there are any other changes made to the project as I am new to sharpmap and learning to use the WMS layer using shapefiles.....

Regards,

MHV

 

Coordinator
Apr 9, 2010 at 10:20 AM

Hello mhv5362,

John did some work on the Shapefile provider in order to allow multiple access to the shapefile. I don't know how far he had gotten, you may examine for yourself. The source is here:

http://code.google.com/p/sharpmapv2/source/browse/#svn/branches/ShapeFileProviderMultiAccess

Hth FObermaier

Sep 5, 2013 at 2:09 PM
Edited Sep 5, 2013 at 5:12 PM
I have the latest release (1.0 Final) and I am still experiencing this issue on the index files.

System.IO.IOException: The process cannot access the file 'temp.shp.sidx' because it is being used by another process.

Has anyone been able to have multiple processes use the same shape and index files?

To resolve this I simply set filebasedindex to false while keeping useMemCache true. The speed did not seem to differ much and this seems better since I do not need to worry about file system issues.
Coordinator
Sep 6, 2013 at 7:25 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.