url源上的outofmemoryexception

时间:2013-08-15 07:55:13

标签: c# wpf xaml

我有这段代码从网址中提取图片

<Window x:Class="ImageTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Image Source="http://theworldsnotes.com/images/Spoils_logo_trans.png"/>
    </Grid>
</Window>

在大多数情况下工作正常,但有些用户遇到以下异常

System.OutOfMemoryException:  There is not enough memory to continue the execution of a program
   vid System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   vid MS.Win32.WinInet.get_InternetCacheFolder()
   vid System.Windows.Media.Imaging.BitmapDownload.BeginDownload(BitmapDecoder decoder, Uri uri, RequestCachePolicy uriCachePolicy, Stream stream)
   vid System.Windows.Media.Imaging.LateBoundBitmapDecoder..ctor(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy requestCachePolicy)
   vid System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
   vid System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
   vid System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   vid MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
   vid MS.Internal.Data.DefaultValueConverter.ConvertFrom(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture)
   vid System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)
   vid System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   vid MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   vid MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView)
   vid MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
   vid System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
   vid System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   vid System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
   vid System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   vid MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   vid System.Windows.Threading.DispatcherOperation.InvokeImpl()
   vid System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   vid System.Windows.Threading.DispatcherOperation.Invoke()
   vid System.Windows.Threading.Dispatcher.ProcessQueue()
   vid System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   vid System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   vid MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   vid System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   vid MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   vid MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   vid System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   vid System.Windows.Application.RunInternal(Window window)
   vid System.Windows.Application.Run()

用户运行的是Windows 7 64位,安装了.net 4.5(应用程序为.net 4.0)。

我让他们运行修复工具,并重新安装.net。

我的想法在这里。我甚至创建了一个应用程序,它只使用WebClient下载图像并将它们保存到文件中,并且它们很好。它也不仅仅是一个不起作用的图像网址,而是关于我可以在程序中投入的任何图像网址(来自不同的域等)。

用户还拥有avast和microsoft安全必备软件,但您认为这会阻止其他测试应用程序正确下载图像。

任何可能导致此问题的想法?我不知道,似乎是一个bug,我倾向于显卡驱动程序问题,但不确定。

0 个答案:

没有答案