title: An exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Phone.ni.dll but was not handled in user code
body: <p>This code is in the ScheduledTaskAgent.cs and ofcourse runs in the background.</p>
  
  <p>I always get this exception at the statement   : stream.Seek(0, SeekOrigin.Begin);
   The image is in my project files under the root.I tried with "Do Not Copy" and "Always Copy".But still the same error comes.</p>
  
  <pre><code>Deployment.Current.Dispatcher.BeginInvoke(()=&gt;
               { 
                   BitmapImage img = new BitmapImage(new Uri(@"\DefaultImage.jpg", UriKind.Relative));
                   img.CreateOptions = BitmapCreateOptions.None;
                   img.ImageOpened += (s, e) =&gt;
                   {
                       WriteableBitmap wbitmap = new WriteableBitmap((BitmapImage)s);
                       TextBlock textBlock = new TextBlock();                       
                       textBlock.Text = "Sample Text";
                       textBlock.TextWrapping = TextWrapping.Wrap;
                       wbitmap.Render(textBlock, new TranslateTransform() { X = 25, Y = 10 }); ;
                       wbitmap.Invalidate();
  
                       using (MemoryStream stream = new MemoryStream())
                       {                    
                           wbitmap.SaveJpeg(stream, wbitmap.PixelWidth, wbitmap.PixelHeight, 0, 100);
                           stream.Seek(0, SeekOrigin.Begin);
                           SaveToIsolatedStorage(stream);
                           stream.Close();
                       }
                   };
         });
  </code></pre>