Ask a questionAsk a question
 

AnswerException Occurred in Window Vista

  • Monday, April 28, 2008 10:32 PMBetty Tjandra Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Hi,

    I have a WPF application, I am able to run on my XP operation System and also My Vista 64-bits.  But, when I run my application in my Vista 32-bits I have the exception. it said "First chance exception of type System.ArgumentException occurred in Presentation.dll.  This exception came from the following call

    Image.EndInit().

     

    Here's part of my code:

     

    public object Convert(object value, Type targetType,
                object parameter, System.Globalization.CultureInfo culture)
            {
                // value contains the full path to the image
                string path = (string)value;

                // load the image, specify CacheOption so the file is not locked
                BitmapImage image = new BitmapImage();

                if (path != null)
                {
                    image.BeginInit();

                    if (parameter != null) // this is the thumbnail size parameter
                    {
                        int thumbnailMaxHeight = System.Convert.ToInt32(parameter);

                        // Set the max pixel height.  This number determines
                        // how big of a thumbnail to load. The smaller the number, the
                        // quicker the load, the lower the quality.

                        image.DecodePixelHeight = thumbnailMaxHeight;
                    }
                    image.CacheOption = BitmapCacheOption.OnLoad;

                    image.UriSource = new Uri(path);
                    System.Console.WriteLine("path =" + path);
                    try
                    {
                        image.EndInit();
                    }
                    catch (InvalidOperationException ie)
                    {
                        System.Console.WriteLine(ie.StackTrace);
                    }
                    System.Console.WriteLine("after EndInit = " + path);
                }
                return image;
            }

     

    when I do the view exception detail:

     

    System.ArgumentException    ["Value does not fall within the expected range"]

    Source: mscorlib

    StackTrace:

    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
       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.BitmapImage.FinalizeCreation()
       at System.Windows.Media.Imaging.BitmapImage.EndInit()
       at SearchGadgetDeux.ImagePathConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) in C:\FutureUDOP\SearchGadgetDeux\Util\Converters.cs:line 212
       at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
       at System.Windows.Data.BindingExpression.Activate(Object item)
       at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
       at System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)
       at System.Windows.Data.BindingExpressionBase.OnAttach(DependencyObject d, DependencyProperty dp)
       at System.Windows.StyleHelper.GetInstanceValue(UncommonField`1 dataField, DependencyObject container, FrameworkElement feChild, FrameworkContentElement fceChild, Int32 childIndex, DependencyProperty dp, Int32 i, EffectiveValueEntry& entry)
       at System.Windows.TemplateApplicationHelper.SetDependencyValueCore(DependencyObject dependencyObject, DependencyProperty dp, Object value)
       at System.Windows.Markup.BamlRecordReader.SetDependencyValue(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)
       at System.Windows.Markup.BamlRecordReader.SetDependencyComplexProperty(Object currentTarget, BamlAttributeInfoRecord attribInfo, Object o)

     

     

    I don't have this problem in my XP and my Vista 64 bits. 

    I am usiong .NET Framework 3.5 on all of the machine.  Wonder if something in my Vista 32-bits need to reinstall or something.

     

    Please Help.

     

    Thanks

    Betty

     

Answers

All Replies