Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ManagementEventWatcher affects WPF Image Control

$
0
0

Hi Guys

We're using the ManagmentEventWatcher to monitor if an USB device is removed or added during application life-cycle. 

  var q = new WqlEventQuery();
  q.EventClassName = "__InstanceCreationEvent";
  q.WithinInterval = new TimeSpan(0, 0, UsbMonitoringPollingInterval);
  q.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
  deviceArrivedWatcher = new ManagementEventWatcher(managementScope, q);
  deviceArrivedWatcher.EventArrived += deviceArrivedWatcher_EventArrived;
  deviceArrivedWatcher.Start();

Somehow this affects the WPF Image control. When using the USB Monitoring the Image control throws a FileNotFoundException altough the image is available (e.g. by IE). 

System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value 'http://localhost/TouchWall/Content/AnswerImages/1-2.png' (type 'String'); fallback value will be used, if available. BindingExpression:Path=CurrentQuestion.Answers[1].Image; DataItem='QuestionnaireViewModel' (HashCode=42904617); target element is 'Image' (Name='SecondImage'); target property is 'Source' (type 'ImageSource') FileNotFoundException:'System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at MS.Win32.WinInet.get_InternetCacheFolder()
   at System.Windows.Media.Imaging.BitmapDownload.BeginDownload(BitmapDecoder decoder, Uri uri, RequestCachePolicy uriCachePolicy, Stream stream)
   at System.Windows.Media.Imaging.LateBoundBitmapDecoder..ctor(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy requestCachePolicy)
   at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
   at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
   at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
   at MS.Internal.Data.TargetDefaultValueConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
   at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in PresentationCore.dll
I have no idea why the ManagmentEventWatcher affects the download of an image. When I copy the URL directly in the WPF image source property it's working. 

Thanks for your help! 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>