ThinkGeo.com    |     Documentation    |     Premium Support

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

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



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

 the same error when i try to refresh 1 overlay:


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


i can't figure out why is this so?



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

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

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

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

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

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

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