2011-02-04 16 views
9

He escrito una aplicación WPF en .NET 4.0.La aplicación WPF no se iniciará debido a System.IO.FileFormatException()

he instalado y ejecutado con éxito la aplicación en los siguientes sistemas operativos:

  • Windows XP SP2
  • Vista
  • Windows 7 (32 bits)
  • Windows 7 (64 bits)

Después de instalar la aplicación en una máquina con Windows XP SP3, la aplicación no se inició. Revisé los registros de aplicación del Visor de sucesos y encontré el siguiente error:

Application: ApplicationName.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.IO.FileFormatException 
Stack: 
    at System.Windows.Media.Imaging.BitmapFrameDecode.EnsureThumbnail() 
    at System.Windows.Media.Imaging.BitmapFrameDecode.get_Thumbnail() 
    at MS.Internal.AppModel.IconHelper.GetBestMatch(System.Collections.ObjectModel.ReadOnlyCollection`1<System.Windows.Media.Imaging.BitmapFrame>, System.Windows.Size) 
    at MS.Internal.AppModel.IconHelper.CreateIconHandleFromImageSource(System.Windows.Media.ImageSource, System.Windows.Size) 
    at MS.Internal.AppModel.IconHelper.GetIconHandlesFromImageSource(System.Windows.Media.ImageSource, IconHandle ByRef, IconHandle ByRef) 
    at System.Windows.Window.UpdateIcon() 
    at System.Windows.Window.SetupInitialState(Double, Double, Double, Double) 
    at System.Windows.Window.CreateSourceWindow(Boolean) 
    at System.Windows.Window.CreateSourceWindowDuringShow() 
    at System.Windows.Window.SafeCreateWindowDuringShow() 
    at System.Windows.Window.ShowHelper(System.Object) 
    at System.Windows.Window.Show() 
    at ApplicationName.App.LoadMainWindow() 
    at ApplicationName.App.OnStartup(System.Windows.StartupEventArgs) 
    at System.Windows.Application.<.ctor>b__1(System.Object) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) 
    at System.Windows.Threading.DispatcherOperation.InvokeImpl() 
    at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) 
    at System.Threading.ExecutionContext.runTryCode(System.Object) 
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) 
    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
    at System.Windows.Threading.DispatcherOperation.Invoke() 
    at System.Windows.Threading.Dispatcher.ProcessQueue() 
    at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 
    at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) 
    at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) 
    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) 
    at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) 
    at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 
    at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 
    at System.Windows.Threading.Dispatcher.Run() 
    at System.Windows.Application.RunDispatcher(System.Object) 
    at System.Windows.Application.RunInternal(System.Windows.Window) 
    at System.Windows.Application.Run(System.Windows.Window) 
    at ApplicationName.App.Main() 

así que supongo que tiene algo que ver una de las imágenes que tengo en una de mis ventanas, pero no está seguro de qué;)

¿Alguien ha visto esta excepción antes y tiene una solución?

Nota: En caso de que sea relevante, mi instalador carga WIC y el .NET Framework 4.0 completo en la máquina de destino, cuando sea necesario.

+0

¿Está 100% seguro de que la máquina de destino tiene el último service pack del .NET Framework al que se dirige? – abramlimpin

+0

No tengo la máquina aquí, pero a menos que esté equivocado, .Net Framework lanzó la excepción. La segunda línea del registro de errores mostró 'Framework Version: v4.0.30319', así que supongo que es la versión instalada. –

+0

Si tiene algo que ver con el/los problema/s de fuente, es posible que desee consultar este enlace: http://forums.silverlight.net/forums/p/176008/396460.aspx – abramlimpin

Respuesta

3

Tendría que sugerir que posiblemente el/a archivo de icono de ventana está en formato .png, convirtiendo el archivo a .jpeg y reintentar debería valer la pena.

Tenga en cuenta que intrigante, la depuración con Visual Studio en la aparentemente defectuoso máquina en realidad no tiene problemas, en mi experiencia.

Mis disculpas por no tener ninguna referencia con respecto a este asunto, pero me fue revelada por autoinvestigación ya que la investigación arrojó resultados menores que los escasos. Trataré de ver si hay alguna información ahora, como lo fue hace algún tiempo.

EDIT:

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9e723d51-0e26-4609-8fe1-5e0edcf7385b

How do I get an Icon from a png image?

+0

Quité el icono de la ventana como sugirió y ya no recibí la excepción. Cambiaré la imagen de .ico a .jpeg y veré cómo va eso. Gracias por la ayuda. –

+0

Eche un vistazo a la fragilidad de sus imágenes * .ico, puede ser parte del problema junto con el formato inicial (no soy experto en el almacenamiento interno de archivos de iconos) - intente guardar su icono con diferente color rangos. –

+0

http://connect.microsoft.com/VisualStudio/feedback/details/321285/wpf-application-fails-if-window-icon-is-a-vista-ico-file – JulianM

8

Gracias por los consejos sobre la misma cuestión. Descubrí que tenía la propiedad Icon configurada en un ICO dentro de la propiedad Shell.xaml Window. Quité eso que da la ventana sin icono cuando corro en VS. Sin embargo, fui a las propiedades del proyecto y seleccioné el ícono allí (VS encontró el icono en mi carpeta de recursos, ¡genial!). Cuando la aplicación crea el EXE, contiene el ICO y una agradable sorpresa es que ahora la ventana tiene el mismo ícono.

Cuestiones relacionadas