[Shapelib] ShapeLib problem with SHPDestroyObject Method in .NET 1.1

Mahesh Anandan mahesh_anandan at comcast.net
Mon Jun 12 10:22:49 PDT 2006


Thanks for your response and apologies for not being very clear with my
question. Let me try to explain again. 

I am using the Shapelib library to create shape files (polygons, lines and
points). My data sources are ArcSDE, Shape files and oracle spatial. I am
using Shape library to extract data from these sources and creating shape
file. I like ShapeLib and I have used it in the past in J2EE Environments.
This is the first time I am using in .NET Environment. 

Shape files I am creating using Shapelib is good. I can open them on all
products that supports shape files. I can open my shape files in ArcView/
Map objects/ ArcMap/ Explorer, Maptools etc., 

I use the following method to create the Shape object:

[DllImport("shapelib.dll", CharSet=CharSet.Ansi)]
public static extern SHPObject SHPCreateObject(ShapeType shpType, 
			int ShapeId,
			int nParts, int[] panPartStart, PartType[]
paPartType,
			int nVertices, double[] adfX, double[] adfY,
			double[] adfZ, double[] adfM );

The documentation says, Destroy must be called for Shape Objects created
from CreateObject or ReadObject. 


When calling the Method SHPDestroyObject - Method available in the .NET
Wrapper :

		[DllImport("shapelib.dll", CharSet=CharSet.Ansi)]
		public static extern void SHPDestroyObject(SHPObject
psObject);

I am getting a Null pointer exception (i.e. Object reference not set to an
instance of an object) I am checking if the shape object I am attempting to
destroy is valid or not (i.e. I am checking if its null ) before calling the
destroy method. 

>> You can resolve it by registering the Adodb.dll file in the global
assembly cache
<<

I am not sure I understand you. ADODB.dll? I am not sure why ADODB.dll is
coming in the picture, Please give me more information. Just so you know, I
am not using shapelib to read the shape files. However, My nunit tests are
using the read methods and they seem to come out just fine. My test is quite
simple, I try to open the shape file, try to read the first shape and if the
polygon checks out ok, my unit test passes. Quite simple. My problem is when
creating those shape files.

Shape files I am creating using the shapelib are opening just fine with any
product that can understand shape files. 

However, I see memory allocated for the shape object (SHPObject) is not
destroyed properly because of that exception. My application is not crashing
because I have wrapped the destroy object in try/catch block. For example,
on my 2GB Physical Memory - When the process starts to create the shape
file, I see the utilized memory is at 410MB, I see steady increase in memory
during export and at the end, the memory utilization is at 620MB. With every
shape file I am creating I am seeing this consistent 100 to 200 MB Memory
increase and not released. 

I tried calling the GC From .NET Explicitly, I tried setting the Shape
Object returned by the ShpCreateObject to null - no luck. I even tried to
take the source  code and compiled and played with the threading model etc.,
no luck. I do see some posting on the internet about this problem with no
solution. 

Hope I answered your question with more information, Appreciate your
response and let me know -- 

Thanks 

Mahesh 
 
-----Original Message-----
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of
shapelib-request at lists.maptools.org
Sent: Monday, June 12, 2006 10:01 AM
To: shapelib at lists.maptools.org
Subject: Shapelib Digest, Vol 27, Issue 2

Send Shapelib mailing list submissions to
	shapelib at lists.maptools.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.maptools.org/mailman/listinfo/shapelib
or, via email, send a message with subject or body 'help' to
	shapelib-request at lists.maptools.org

You can reach the person managing the list at
	shapelib-owner at lists.maptools.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Shapelib digest..."


Today's Topics:

   1. RE: Shapelib Digest, Vol 27, Issue 1 (venkatesh)
   2. Re: ShapeLib problem with SHPDestroyObject Method in	.NET	1.1
      (David.Gancarz at ci.orlando.fl.us)


----------------------------------------------------------------------

Message: 1
Date: Mon, 12 Jun 2006 17:26:16 +0530
From: "venkatesh" <venkatesh at amogha.com>
Subject: [Shapelib] RE: Shapelib Digest, Vol 27, Issue 1
To: <shapelib at lists.maptools.org>
Message-ID: <200606121157.k5CBvFc0005127 at duke.maptools.org>
Content-Type: text/plain;	charset="us-ascii"

Hi,
 I didn't get your question exactly? Have you tested whether your program
can access information from shape files or not? You written that your trying
to draw polygon, poly line etc but from where you r getting?

I think, the error msg that you given is not related to code it's related to
.NET environment. Initially I also got same error. You can resolve it by
registering the Adodb.dll file in the global assembly cache.

Hope it helps you.
Cheers,
Venkatesh.

-----Original Message-----
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of
shapelib-request at lists.maptools.org
Sent: Saturday, June 10, 2006 9:33 PM
To: shapelib at lists.maptools.org
Subject: Shapelib Digest, Vol 27, Issue 1

Send Shapelib mailing list submissions to
	shapelib at lists.maptools.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.maptools.org/mailman/listinfo/shapelib
or, via email, send a message with subject or body 'help' to
	shapelib-request at lists.maptools.org

You can reach the person managing the list at
	shapelib-owner at lists.maptools.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Shapelib digest..."


Today's Topics:

   1. ShapeLib problem with SHPDestroyObject Method in .NET	1.1 
      (Mahesh Anandan)


----------------------------------------------------------------------

Message: 1
Date: Sat, 10 Jun 2006 02:19:47 -0600
From: "Mahesh Anandan" <mahesh_anandan at comcast.net>
Subject: [Shapelib] ShapeLib problem with SHPDestroyObject Method in
	.NET	1.1 
To: <shapelib-admin at lists.maptools.org>, <shapelib at lists.maptools.org>
Message-ID: <200606100821.k5A8L7Nt007463 at duke.maptools.org>
Content-Type: text/plain; charset="us-ascii"

Hi, 

 

I am using Shapelib to create Polygon, polyline and point layers. I am using
.NET Wrapper available for the shapelib. 

 

My Problem: 

 

I am creating shape object using the Following method. 

 

ShapeLib.SHPObject shapeObject = ShapeLib.SHPCreateObject.

 

After writing the shape returned by the create object method, I destroy the
object. I am consistently getting Access Violation error when calling the
following method. 

 

ShapeLib.SHPDestroyObject(shapeObject);

 

Exact error message is: Object reference not set to an instance of an
object.

 

For now, I am checking for shapeObject != null and also wrapped this in a
try catch block. It did not make any difference. I am fighting with this
problem for the last 3 weeks. Appreciate your response at the earliest.

 

Thank you,

 

MAHESH ANANDAN

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.maptools.org/pipermail/shapelib/attachments/20060610/bb411961/a
ttachment-0001.html

------------------------------

_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib


End of Shapelib Digest, Vol 27, Issue 1
***************************************



------------------------------

Message: 2
Date: Mon, 12 Jun 2006 08:36:37 -0400
From: David.Gancarz at ci.orlando.fl.us
Subject: Re: [Shapelib] ShapeLib problem with SHPDestroyObject Method
	in	.NET	1.1
To: Shapelib Development <shapelib at lists.maptools.org>
Message-ID:
	
<OF06417EFB.48438EB9-ON8525718B.0044B4E0-8525718B.00452901 at ci.orlando.fl.us>
	
Content-Type: text/plain; charset="us-ascii"

Mahesh:  I just saw you message this Monday morning.  The problem you are 
having is a bug in the .Net wrapper. I fixed it long ago but have never 
been able to get the new version posted to the shapelib site.  I am 
sending the correct version to you by private message.

Best regards,

David Gancarz




"Mahesh Anandan" <mahesh_anandan at comcast.net> 
Sent by: shapelib-bounces at lists.maptools.org
06/10/2006 04:19 AM
Please respond to
Shapelib Development <shapelib at lists.maptools.org>


To
<shapelib-admin at lists.maptools.org>, <shapelib at lists.maptools.org>
cc

Subject
[Shapelib] ShapeLib problem with SHPDestroyObject Method in .NET 1.1






Hi, 
 
I am using Shapelib to create Polygon, polyline and point layers. I am 
using .NET Wrapper available for the shapelib. 
 
My Problem: 
 
I am creating shape object using the Following method. 
 
ShapeLib.SHPObject shapeObject = ShapeLib.SHPCreateObject.
 
After writing the shape returned by the create object method, I destroy 
the object. I am consistently getting Access Violation error when calling 
the following method. 
 
ShapeLib.SHPDestroyObject(shapeObject);
 
Exact error message is: Object reference not set to an instance of an 
object.
 
For now, I am checking for shapeObject != null and also wrapped this in a 
try catch block. It did not make any difference. I am fighting with this 
problem for the last 3 weeks. Appreciate your response at the earliest.
 
Thank you,
 
MAHESH ANANDAN_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.maptools.org/pipermail/shapelib/attachments/20060612/ae1878fd/a
ttachment-0001.html

------------------------------

_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib


End of Shapelib Digest, Vol 27, Issue 2
***************************************




More information about the Shapelib mailing list