title: NullReferenceException when trying to add a BitmapImage to ObservableCollection (WP8)
body: <p>The problem is here:</p>
  
  <pre><code>var allImages = commentXml.Elements("Image");
       if (allImages != null)
       {
           foreach (var image in allImages)
           {                            
               string base64string = GetElementValue(image.Element("Data"));
               MessageBox.Show(base64string);
               BitmapImage currentImage = await GetImageFromBase64String(base64string);
               MessageBox.Show(currentImage.PixelWidth.ToString());
               comment.Images.Add(currentImage);
           }
       }
  </code></pre>
  
  <p>The first MessageBox tells that base64string exists, the second MessageBox returns image width, but the last line throws NullReferenceException. Why this is going on? comment.Images object has ObservableCollection type.</p>
  
  <p>Here's also GetImageFromBase64String function, but I'm think it's ok.</p>
  
  <pre><code>public async Task&lt;BitmapImage&gt; GetImageFromBase64String(string value)
      {
          if (value == null)
              return null;
  
          var buffer = System.Convert.FromBase64String(value);
          MemoryStream ms = new MemoryStream();
          DataWriter writer = new DataWriter(ms.AsOutputStream());
          writer.WriteBytes(buffer);
          await writer.StoreAsync();
          var image = new BitmapImage();
          image.SetSource(ms);
          return image;
  
      }
  </code></pre>