# Exception while opening a shapefile

**URL:** <https://community.thinkgeo.com/t/exception-while-opening-a-shapefile/453>\
**Category:** WinForms\
**Created:** [June 2, 2009, 3:56pm UTC](https://community.thinkgeo.com/t/exception-while-opening-a-shapefile/453 "2009-06-02T15:56:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@Patrick](https://community.thinkgeo.com/u/Patrick)\
**Post date:** [June 2, 2009, 3:56pm UTC](https://community.thinkgeo.com/t/exception-while-opening-a-shapefile/453/1 "2009-06-02T15:56:00Z")

</div>

Hello,

I'm&nbsp;experiencing&nbsp;exception&nbsp;when&nbsp;I&nbsp;try&nbsp;to&nbsp;open&nbsp;more&nbsp;than&nbsp;one&nbsp;shapefile.

Please&nbsp;note&nbsp;that&nbsp;these&nbsp;files&nbsp;can&nbsp;be&nbsp;opened&nbsp;without&nbsp;troubles&nbsp;with&nbsp;MS&nbsp;3.0.199&nbsp;and&nbsp;with&nbsp;MS&nbsp;3.0.307&nbsp;single&nbsp;threaded.  
  
The&nbsp;exception&nbsp;occurs&nbsp;only&nbsp;when&nbsp;I&nbsp;use&nbsp;3.0.307&nbsp;in&nbsp;multithread&nbsp;mode&nbsp;(VS2008&nbsp;under&nbsp;64bits&nbsp;platform)

L'exception&nbsp;System.IO.FileLoadException&nbsp;n'a&nbsp;pas&nbsp;été&nbsp;gérée  
  
&nbsp;&nbsp;Message="The&nbsp;record&nbsp;is&nbsp;invalid,&nbsp;please&nbsp;call&nbsp;Validate&nbsp;method&nbsp;to&nbsp;check&nbsp;the&nbsp;failed&nbsp;reason.Record&nbsp;index:&nbsp;31"  
  
&nbsp;&nbsp;Source="MapSuiteCore"  
  
&nbsp;&nbsp;StackTrace:  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.Core.xdad12102199d8695.ReadRecord(Int32&nbsp;recordIndex)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.GetFeaturesForDrawingCore(RectangleShape&nbsp;boundingBox,&nbsp;Double&nbsp;screenWidth,&nbsp;Double&nbsp;screenHeight,&nbsp;IEnumerable`1&nbsp;returningColumnNames)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawing(RectangleShape&nbsp;boundingBox,&nbsp;Double&nbsp;screenWidth,&nbsp;Double&nbsp;screenHeight,&nbsp;IEnumerable`1&nbsp;returningColumnNames)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas&nbsp;canvas,&nbsp;Collection`1&nbsp;labelsInAllLayers)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas&nbsp;canvas,&nbsp;Collection`1&nbsp;labelsInAllLayers)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas&nbsp;canvas)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas&nbsp;canvas)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x27d0591c2adda8d9(RectangleShape&nbsp;xb35a33b423b17f65,&nbsp;Overlay&nbsp;x99251f66cdabc2ad,&nbsp;Int32&nbsp;xa209325f5c895f7e,&nbsp;Int32&nbsp;x7454a0d1965919b1,&nbsp;GeographyUnit&nbsp;xbb704b4400ce6f76)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x27d0591c2adda8d9(Object&nbsp;x9c95f4613bdc3113)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;System.Threading.ExecutionContext.Run(ExecutionContext&nbsp;executionContext,&nbsp;ContextCallback&nbsp;callback,&nbsp;Object&nbsp;state)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;System.Threading.\_ThreadPoolWaitCallback.PerformWaitCallbackInternal(\_ThreadPoolWaitCallback&nbsp;tpWaitCallBack)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;à&nbsp;System.Threading.\_ThreadPoolWaitCallback.PerformWaitCallback(Object&nbsp;state)  
  
&nbsp;&nbsp;InnerException:&nbsp;

Please&nbsp;help,&nbsp;we&nbsp;are&nbsp;so&nbsp;late&nbsp;in&nbsp;the&nbsp;schedule.

Patrick.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 2, 2009, 9:19pm UTC](https://community.thinkgeo.com/t/exception-while-opening-a-shapefile/453/2 "2009-06-02T21:19:30Z")

</div>

Patrick,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;for&nbsp;the&nbsp;inconvenience!&nbsp;I&nbsp;will&nbsp;try&nbsp;my&nbsp;best&nbsp;to&nbsp;move&nbsp;forward&nbsp;with&nbsp;you!&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;just&nbsp;want&nbsp;to&nbsp;make&nbsp;sure,&nbsp;you&nbsp;means&nbsp;open&nbsp;more&nbsp;than&nbsp;one&nbsp;shape&nbsp;file&nbsp;by&nbsp;adding&nbsp;more&nbsp;than&nbsp;one&nbsp;shapeFileFeatureLayer&nbsp;into&nbsp;a&nbsp;LayerOverlay&nbsp;and&nbsp;added&nbsp;it&nbsp;to&nbsp;the&nbsp;MapControl&nbsp;and&nbsp;then&nbsp;call&nbsp;Refresh()?&nbsp;I&nbsp;think&nbsp;in&nbsp;many&nbsp;our&nbsp;samples,&nbsp;it&nbsp;did&nbsp;in&nbsp;this&nbsp;way&nbsp;and&nbsp;seems&nbsp;have&nbsp;no&nbsp;problem.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Can&nbsp;you&nbsp;try&nbsp;to&nbsp;load&nbsp;multiple&nbsp;shape&nbsp;files&nbsp;which&nbsp;is&nbsp;accompanied&nbsp;in&nbsp;the&nbsp;Installer&nbsp;HowDoIsamples&#160;SampleData&nbsp;folder?&nbsp;Or&nbsp;can&nbsp;you&nbsp;provide&nbsp;us&nbsp;your&nbsp;sample&nbsp;code&nbsp;snippet&nbsp;and&nbsp;shape&nbsp;files&nbsp;used&nbsp;if&nbsp;possible?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Patrick](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@Patrick](https://community.thinkgeo.com/u/Patrick)\
**Post date:** [June 23, 2009, 1:43am UTC](https://community.thinkgeo.com/t/exception-while-opening-a-shapefile/453/3 "2009-06-23T01:43:21Z")

</div>

I&nbsp;found&nbsp;the&nbsp;way&nbsp;to&nbsp;reproduce&nbsp;the&nbsp;issue&nbsp;very&nbsp;easily&nbsp;(3.0.331)&nbsp;  
&nbsp;&nbsp;  
&nbsp;1.&nbsp;put&nbsp;2&nbsp;mapwinform&nbsp;on&nbsp;a&nbsp;form&nbsp;  
&nbsp;2.&nbsp;switch&nbsp;them&nbsp;to&nbsp;multithread&nbsp;  
&nbsp;3.&nbsp;open&nbsp;in&nbsp;readonly&nbsp;mode&nbsp;a&nbsp;couple&nbsp;of&nbsp;shape&nbsp;files&nbsp;in&nbsp;the&nbsp;first&nbsp;map&nbsp;and&nbsp;the&nbsp;SAME&nbsp;couple&nbsp;of&nbsp;shape&nbsp;files&nbsp;in&nbsp;the&nbsp;second&nbsp;map&nbsp;  
&nbsp;4.&nbsp;play&nbsp;with&nbsp;them&nbsp;(pan,&nbsp;zoom)&nbsp;and&nbsp;you’ll&nbsp;get&nbsp;this&nbsp;exception&nbsp;very&nbsp;fast.&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;same&nbsp;scenario&nbsp;does&nbsp;not&nbsp;crash&nbsp;in&nbsp;singlethread&nbsp;mode.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;help.&nbsp;  
&nbsp;Patrick.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 23, 2009, 4:15am UTC](https://community.thinkgeo.com/t/exception-while-opening-a-shapefile/453/4 "2009-06-23T04:15:31Z")

</div>

Patrick,&nbsp;

Thanks&nbsp;for&nbsp;your&nbsp;post!  
&nbsp;  
We&nbsp;cannot&nbsp;recreate&nbsp;your&nbsp;problem,&nbsp;attachment&nbsp;is&nbsp;our&nbsp;demo&nbsp;you&nbsp;can&nbsp;have&nbsp;a&nbsp;try(before&nbsp;you&nbsp;run,&nbsp;please&nbsp;copy&nbsp;the&nbsp;cntry02.shp&nbsp;file&nbsp;to&nbsp;the&nbsp;PostData&nbsp;folder)!  
&nbsp;  
If&nbsp;you&nbsp;play&nbsp;with&nbsp;the&nbsp;demo&nbsp;in&nbsp;the&nbsp;attachment&nbsp;and&nbsp;found&nbsp;the&nbsp;exception,&nbsp;please&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Besides,&nbsp;from&nbsp;the&nbsp;exception&nbsp;description&nbsp;at&nbsp;the&nbsp;top&nbsp;of&nbsp;this&nbsp;post,&nbsp;I&nbsp;guess&nbsp;there&nbsp;is&nbsp;some&nbsp;records&nbsp;in&nbsp;your&nbsp;shape&nbsp;file&nbsp;are&nbsp;not&nbsp;valid,&nbsp;can&nbsp;you&nbsp;try&nbsp;the&nbsp;static&nbsp;API&nbsp;mentioned&nbsp;in&nbsp;the&nbsp;description&nbsp;in&nbsp;ShapeFielFeatureSource?&nbsp;Or&nbsp;can&nbsp;you&nbsp;give&nbsp;us&nbsp;your&nbsp;data?  
&nbsp;  
Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Thanks.  
&nbsp;  
Yale  
  
[798-Post5818\_Demo.zip](https://community.thinkgeo.com/uploads/default/original/2X/3/3717436cb2a763cf267a130b0f9fdd51ba33be6c.zip) (10.7 KB)
