# Value of 'null' is not valid for 'stream'

**URL:** <https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080>\
**Category:** WinForms\
**Created:** [March 2, 2010, 6:24am UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080 "2010-03-02T06:24:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricky](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@Ricky](https://community.thinkgeo.com/u/Ricky)\
**Post date:** [March 2, 2010, 6:24am UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/1 "2010-03-02T06:24:46Z")

</div>

i&nbsp;have&nbsp;a&nbsp;simple&nbsp;code&nbsp;but&nbsp;dont&nbsp;know&nbsp;why&nbsp;when&nbsp;i&nbsp;try&nbsp;to&nbsp;refresh&nbsp;the&nbsp;map,&nbsp;error&nbsp;occured&nbsp;that&nbsp;says:&nbsp;"Value&nbsp;of&nbsp;'null'&nbsp;is&nbsp;not&nbsp;valid&nbsp;for&nbsp;'stream'"...

`Feature feature = new Feature(worldP.X, worldP.Y, "car");InMemoryFeatureLayer markerLayer = (InMemoryFeatureLayer)wpfMap1.FindFeatureLayer("MarkerLayer");markerLayer.InternalFeatures.Add("car", feature);wpfMap1.Refresh();`

&nbsp;the&nbsp;same&nbsp;error&nbsp;when&nbsp;i&nbsp;try&nbsp;to&nbsp;refresh&nbsp;1&nbsp;overlay:

wpfMap1.Refresh(wpfMap1.Overlays["MarkerOverlay"]);

i&nbsp;can't&nbsp;figure&nbsp;out&nbsp;why&nbsp;is&nbsp;this&nbsp;so?

---

<div class="post-metadata">

**Author:** ![Ricky](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@Ricky](https://community.thinkgeo.com/u/Ricky)\
**Post date:** [March 2, 2010, 7:29am UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/2 "2010-03-02T07:29:51Z")

</div>

Sorry&nbsp;guys,&nbsp;this&nbsp;error&nbsp;occured&nbsp;because&nbsp;the&nbsp;file&nbsp;was&nbsp;not&nbsp;found.&nbsp;The&nbsp;error&nbsp;presented&nbsp;was&nbsp;not&nbsp;obvious.&nbsp;Solved.

---

<div class="post-metadata">

**Author:** ![Ryan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@Ryan](https://community.thinkgeo.com/u/Ryan)\
**Post date:** [March 2, 2010, 10:49am UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/3 "2010-03-02T10:49:51Z")

</div>

Ric,&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Glad&nbsp;it&nbsp;is&nbsp;working&nbsp;for&nbsp;you.&nbsp;We&nbsp;will&nbsp;take&nbsp;a&nbsp;look&nbsp;at&nbsp;that&nbsp;exception&nbsp;to&nbsp;see&nbsp;if&nbsp;can’t&nbsp;be&nbsp;made&nbsp;more&nbsp;descriptive.

---

<div class="post-metadata">

**Author:** ![David4](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@David4](https://community.thinkgeo.com/u/David4)\
**Post date:** [June 14, 2010, 11:40pm UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/4 "2010-06-14T23:40:13Z")

</div>

Has&nbsp;this&nbsp;been&nbsp;done?&nbsp;I&nbsp;am&nbsp;getting&nbsp;the&nbsp;same&nbsp;error&nbsp;message&nbsp;on&nbsp;this&nbsp;line:&nbsp;  
&nbsp;&nbsp;  
&nbsp;WinformsMap1.Refresh()&nbsp;  
&nbsp;&nbsp;  
&nbsp;running&nbsp;version&nbsp;3.0.0.0&nbsp;of&nbsp;DesktopEdition.&nbsp;I&nbsp;can’t&nbsp;really&nbsp;tell&nbsp;why&nbsp;it&nbsp;is&nbsp;happening.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [June 15, 2010, 8:50pm UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/5 "2010-06-15T20:50:24Z")

</div>

David,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Can&nbsp;you&nbsp;past&nbsp;in&nbsp;the&nbsp;stack&nbsp;trace&nbsp;for&nbsp;your&nbsp;error?&nbsp;&nbsp;Can&nbsp;you&nbsp;also&nbsp;show&nbsp;the&nbsp;code&nbsp;you&nbsp;think&nbsp;is&nbsp;generating&nbsp;it?&nbsp;&nbsp;We&nbsp;need&nbsp;a&nbsp;little&nbsp;more&nbsp;info&nbsp;to&nbsp;help&nbsp;out&nbsp;and&nbsp;any&nbsp;information&nbsp;you&nbsp;can&nbsp;provide&nbsp;will&nbsp;speed&nbsp;up&nbsp;the&nbsp;resolution.&nbsp;:-)&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![David4](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@David4](https://community.thinkgeo.com/u/David4)\
**Post date:** [June 15, 2010, 10:38pm UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/6 "2010-06-15T22:38:27Z")

</div>

Actually&nbsp;I&nbsp;just&nbsp;found&nbsp;the&nbsp;problem&nbsp;a&nbsp;couple&nbsp;of&nbsp;hours&nbsp;ago.&nbsp;In&nbsp;fact&nbsp;same&nbsp;reason&nbsp;as&nbsp;with&nbsp;Ric.&nbsp;An&nbsp;incorrect&nbsp;path&nbsp;resulting&nbsp;in&nbsp;a&nbsp;missing&nbsp;file.&nbsp;The&nbsp;actual&nbsp;line&nbsp;that&nbsp;should&nbsp;have&nbsp;failed&nbsp;in&nbsp;my&nbsp;opinion&nbsp;is&nbsp;this&nbsp;one:&nbsp;  
&nbsp;&nbsp;  
&nbsp;bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image&nbsp;=&nbsp;New&nbsp;GeoImage(“C:\Program&nbsp;Files\ThinkGeo\Map&nbsp;Suite&nbsp;Desktop&nbsp;Full&nbsp;Edition&nbsp;3.0\Samples\SampleData\Images\Prop&nbsp;Plane.png”)&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;path/file&nbsp;didn’t&nbsp;exist&nbsp;so&nbsp;it&nbsp;should&nbsp;have&nbsp;failed&nbsp;here&nbsp;instead&nbsp;of&nbsp;at&nbsp;the&nbsp;Refresh()&nbsp;line.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [June 16, 2010, 6:39am UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/7 "2010-06-16T06:39:25Z")

</div>

Davids,&nbsp;I&nbsp;agree&nbsp;with&nbsp;the&nbsp;assessment&nbsp;that&nbsp;the&nbsp;error&nbsp;should&nbsp;occur&nbsp;at&nbsp;the&nbsp;time&nbsp;the&nbsp;invalid&nbsp;filename&nbsp;is&nbsp;provided,&nbsp;rather&nbsp;than&nbsp;at&nbsp;the&nbsp;refresh.&nbsp;&nbsp;&nbsp;I&nbsp;can&nbsp;appreciate&nbsp;that&nbsp;you&nbsp;don’t&nbsp;open&nbsp;and&nbsp;process&nbsp;the&nbsp;file&nbsp;until&nbsp;a&nbsp;refresh&nbsp;is&nbsp;called&nbsp;and&nbsp;the&nbsp;layer&nbsp;is&nbsp;visible.&nbsp;&nbsp;&nbsp;&nbsp;But&nbsp;sure&nbsp;would&nbsp;be&nbsp;nice&nbsp;to&nbsp;see&nbsp;a&nbsp;diagnostic&nbsp;to&nbsp;indicate&nbsp;the&nbsp;file&nbsp;is&nbsp;missing&nbsp;or&nbsp;parts&nbsp;of&nbsp;a&nbsp;file&nbsp;set&nbsp;are&nbsp;missing&nbsp;at&nbsp;the&nbsp;time&nbsp;the&nbsp;image&nbsp;or&nbsp;feature&nbsp;source&nbsp;is&nbsp;created.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [June 16, 2010, 5:50pm UTC](https://community.thinkgeo.com/t/value-of-null-is-not-valid-for-stream/1080/8 "2010-06-16T17:50:12Z")

</div>

Ted,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;I&nbsp;think&nbsp;you&nbsp;hit&nbsp;the&nbsp;nail&nbsp;on&nbsp;the&nbsp;head.&nbsp;&nbsp;We&nbsp;need&nbsp;to&nbsp;have&nbsp;a&nbsp;better&nbsp;error&nbsp;message&nbsp;to&nbsp;lead&nbsp;people&nbsp;to&nbsp;the&nbsp;issue.&nbsp;&nbsp;The&nbsp;problem&nbsp;is&nbsp;that&nbsp;we&nbsp;did&nbsp;not&nbsp;want&nbsp;to&nbsp;have&nbsp;to&nbsp;do&nbsp;a&nbsp;validation&nbsp;check&nbsp;on&nbsp;the&nbsp;file.&nbsp;&nbsp;It&nbsp;is&nbsp;a&nbsp;disk&nbsp;read&nbsp;and&nbsp;in&nbsp;many&nbsp;scenarios&nbsp;where&nbsp;you&nbsp;read&nbsp;40&nbsp;files&nbsp;+&nbsp;it&nbsp;really&nbsp;delays&nbsp;startup&nbsp;time.&nbsp;:-(&nbsp;&nbsp;I&nbsp;will&nbsp;see&nbsp;if&nbsp;there&nbsp;is&nbsp;any&nbsp;way&nbsp;we&nbsp;can&nbsp;make&nbsp;this&nbsp;better.&nbsp;&nbsp;Maybe&nbsp;we&nbsp;catch&nbsp;the&nbsp;error&nbsp;and&nbsp;re-raise&nbsp;it&nbsp;with&nbsp;a&nbsp;‘Check&nbsp;if&nbsp;the&nbsp;file&nbsp;is&nbsp;missing’&nbsp;kind&nbsp;of&nbsp;exception&nbsp;and&nbsp;then&nbsp;tell&nbsp;the&nbsp;file&nbsp;name.&nbsp;&nbsp;Of&nbsp;course&nbsp;include&nbsp;the&nbsp;source&nbsp;error&nbsp;and&nbsp;stack&nbsp;as&nbsp;well.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David
