# GetBoundingBox error

**URL:** <https://community.thinkgeo.com/t/getboundingbox-error/5259>\
**Category:** WebForms\
**Created:** [March 31, 2010, 11:17am UTC](https://community.thinkgeo.com/t/getboundingbox-error/5259 "2010-03-31T11:17:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@Charles](https://community.thinkgeo.com/u/Charles)\
**Post date:** [March 31, 2010, 11:17am UTC](https://community.thinkgeo.com/t/getboundingbox-error/5259/1 "2010-03-31T11:17:40Z")

</div>

I&nbsp;have&nbsp;a&nbsp;query&nbsp;for&nbsp;an&nbsp;MsSql2008FeatureLayer&nbsp;that&nbsp;returns&nbsp;a&nbsp;single&nbsp;point&nbsp;feature.&nbsp;&nbsp;A&nbsp;single&nbsp;point&nbsp;feature&nbsp;doesn't&nbsp;really&nbsp;have&nbsp;a&nbsp;valid&nbsp;bounding&nbsp;box&nbsp;and&nbsp;I&nbsp;get&nbsp;an&nbsp;error&nbsp;if&nbsp;I&nbsp;try&nbsp;to&nbsp;use&nbsp;the&nbsp;GetBoundingBox&nbsp;method&nbsp;for&nbsp;the&nbsp;layer.&nbsp;&nbsp;I&nbsp;have&nbsp;checked&nbsp;and&nbsp;the&nbsp;point&nbsp;location&nbsp;is&nbsp;valid.&nbsp;&nbsp;The&nbsp;error&nbsp;is&nbsp;as&nbsp;follows:

InvalidCastException:&nbsp;Unable&nbsp;to&nbsp;cast&nbsp;object&nbsp;of&nbsp;type&nbsp;'System.DBNull'&nbsp;to&nbsp;type&nbsp;'System.Byte[]'.]  
&nbsp;&nbsp;&nbsp;ThinkGeo.MapSuite.Core.MsSql2008FeatureSource.GetBoundingBoxCore()&nbsp;+242

The&nbsp;problem&nbsp;is&nbsp;that&nbsp;the&nbsp;HasBoundingBox&nbsp;method&nbsp;returns&nbsp;true&nbsp;for&nbsp;the&nbsp;layer.&nbsp;&nbsp;How&nbsp;can&nbsp;I&nbsp;test&nbsp;to&nbsp;see&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;valid&nbsp;bounding&nbsp;box&nbsp;prior&nbsp;to&nbsp;running&nbsp;the&nbsp;GetBoundingBox&nbsp;method?

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [April 1, 2010, 1:17am UTC](https://community.thinkgeo.com/t/getboundingbox-error/5259/2 "2010-04-01T01:17:52Z")

</div>

Hi&nbsp;Charles,

This&nbsp;is&nbsp;a&nbsp;known&nbsp;issue.&nbsp;We&nbsp;have&nbsp;added&nbsp;it&nbsp;to&nbsp;our&nbsp;work&nbsp;list.&nbsp;Following&nbsp;is&nbsp;a&nbsp;workaround&nbsp;for&nbsp;you,&nbsp;please&nbsp;have&nbsp;a&nbsp;try.

&nbsp;

`int count = sql2008Layer.FeatureSource.GetCount();            RectangleShape boundingBox;            if (count == 1)            {                 boundingBox = sql2008Layer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns)[0].GetBoundingBox();            }            else            {                 boundingBox = sql2008Layer.GetBoundingBox();            }`

Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;let&nbsp;us&nbsp;know.

Thanks,

Johnny

&nbsp;

---

<div class="post-metadata">

**Author:** ![Charles](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@Charles](https://community.thinkgeo.com/u/Charles)\
**Post date:** [April 1, 2010, 7:39am UTC](https://community.thinkgeo.com/t/getboundingbox-error/5259/3 "2010-04-01T07:39:36Z")

</div>

Is&nbsp;the&nbsp;same&nbsp;true&nbsp;of&nbsp;the&nbsp;Feature&nbsp;object&nbsp;or&nbsp;is&nbsp;the&nbsp;problem&nbsp;specific&nbsp;to&nbsp;the&nbsp;MsSql2008FeatureLayer&nbsp;(or&nbsp;the&nbsp;FeatureLayer&nbsp;in&nbsp;general)?&nbsp;&nbsp;Do&nbsp;I&nbsp;need&nbsp;a&nbsp;work&nbsp;around&nbsp;for&nbsp;the&nbsp;Feature.GetBoundingBox()?

Charles

---

<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:** [April 1, 2010, 8:13pm UTC](https://community.thinkgeo.com/t/getboundingbox-error/5259/4 "2010-04-01T20:13:34Z")

</div>

Charles,

Thanks&nbsp;for&nbsp;your&nbsp;post.  
&nbsp;  
This&nbsp;issue&nbsp;only&nbsp;exists&nbsp;in&nbsp;the&nbsp;MsSql2008FeatureLayer,&nbsp;it&nbsp;is&nbsp;expected&nbsp;to&nbsp;work&nbsp;fine&nbsp;when&nbsp;you&nbsp;use&nbsp;the&nbsp;ShapeFileFeatureLayer&nbsp;or&nbsp;feature&nbsp;object.&nbsp;So&nbsp;just&nbsp;give&nbsp;workaround&nbsp;to&nbsp;the&nbsp;MsSql2008FeatureLayer.  
&nbsp;  
Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Thanks.  
&nbsp;  
Yale

---

<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:** [November 25, 2010, 2:25am UTC](https://community.thinkgeo.com/t/getboundingbox-error/5259/5 "2010-11-25T02:25:24Z")

</div>

Charles,&nbsp;  
&nbsp;&nbsp;  
&nbsp;We&nbsp;have&nbsp;fixed&nbsp;this&nbsp;problem&nbsp;by&nbsp;updating&nbsp;our&nbsp;MsSql2008FeatureLayer,&nbsp;please&nbsp;get&nbsp;the&nbsp;lastest&nbsp;version&nbsp;at&nbsp;custom&nbsp;portal&nbsp;and&nbsp;try&nbsp;it&nbsp;again.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Please&nbsp;let&nbsp;me&nbsp;know&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;questions.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;  
&nbsp;James
