Exception Occurred in Window Vista
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
Internally WPF uses some of the same APIs as IE. You can see in your stack trace that the exception was thrown on the WinInet (http://msdn2.microsoft.com/en-us/library/aa383630(VS.85).aspx). This API must still be a work in progress on IE8.
-Jer
- This is a known issue, see other similar discussion here:
http://channel9.msdn.com/ShowPost.aspx?PostID=388896
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2996593&SiteID=1
Hope this helps
All Replies
Would you happen to have IE8 beta installed? What happens if you compile the app as x86 instead of "Any CPU"?
-Jer
Thank you! Yes I have IE8 beta installed, as soon as I uninstalled IE8 my application work now. Could you please tell me why? My application is not using IE at all.
Thanks for your help.
Betty
Internally WPF uses some of the same APIs as IE. You can see in your stack trace that the exception was thrown on the WinInet (http://msdn2.microsoft.com/en-us/library/aa383630(VS.85).aspx). This API must still be a work in progress on IE8.
-Jer
- This is a known issue, see other similar discussion here:
http://channel9.msdn.com/ShowPost.aspx?PostID=388896
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2996593&SiteID=1
Hope this helps


