Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 由于System.IO.FileFormatException()的原因,WPF应用程序将无法启动_.net_Wpf - Fatal编程技术网

.net 由于System.IO.FileFormatException()的原因,WPF应用程序将无法启动

.net 由于System.IO.FileFormatException()的原因,WPF应用程序将无法启动,.net,wpf,.net,Wpf,我已经在.NET4.0中编写了一个WPF应用程序 我已在以下操作系统上安装并成功运行该应用程序: WindowsXPSP2 远景 窗口7(32位) Windows 7(64位) 在使用Windows XP SP3的计算机上安装应用程序后,应用程序无法启动。我检查了事件查看器的应用程序日志,发现以下错误: Application: ApplicationName.exe Framework Version: v4.0.30319 Description: The process was ter

我已经在.NET4.0中编写了一个WPF应用程序

我已在以下操作系统上安装并成功运行该应用程序:

  • WindowsXPSP2
  • 远景
  • 窗口7(32位)
  • Windows 7(64位)
在使用Windows XP SP3的计算机上安装应用程序后,应用程序无法启动。我检查了事件查看器的应用程序日志,发现以下错误:

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()
应用程序:ApplicationName.exe
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.IO.FileFormatException
堆栈:
位于System.Windows.Media.Imaging.BitmapFrameDecode.EnsureThumbnail()处
在System.Windows.Media.Imaging.BitmapFrameDecode.get_缩略图()中
位于MS.Internal.AppModel.IconHelper.GetBestMatch(System.Collections.ObjectModel.ReadOnlyCollection`1,System.Windows.Size)
位于MS.Internal.AppModel.IconHelper.CreateIconHandleFromImageSource(System.Windows.Media.ImageSource,System.Windows.Size)
位于MS.Internal.AppModel.IconHelper.GetIconHandlesFromImageSource(System.Windows.Media.ImageSource、IconHandle ByRef、IconHandle ByRef)
在System.Windows.Window.UpdateIcon()中
在System.Windows.Window.SetupInitialState(双精度、双精度、双精度、双精度)
位于System.Windows.Window.CreateSourceWindow(布尔值)
在System.Windows.Window.CreateSourceWindowDuringShow()中
在System.Windows.Window.SafeCreateWindowDuringShow()中
位于System.Windows.Window.ShowHelper(System.Object)
在System.Windows.Window.Show()中
在ApplicationName.App.LoadMainWindow()处
在ApplicationName.App.OnStartup(System.Windows.StartupEventArgs)上
在System.Windows.Application.b__1(System.Object)中
位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate、System.Object、Int32)
位于MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object、System.Delegate、System.Object、Int32、System.Delegate)
在System.Windows.Threading.DispatcherOperation.InvokeImpl()中
位于System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
位于System.Threading.ExecutionContext.runTryCode(System.Object)
在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuarantedCleanup(TryCode,CleanupCode,System.Object)中
位于System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext、System.Threading.ContextCallback、System.Object)
在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,布尔值)
在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object)上运行
在System.Windows.Threading.DispatcherOperation.Invoke()中
在System.Windows.Threading.Dispatcher.ProcessQueue()中
位于System.Windows.Threading.Dispatcher.WndProcHook(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef)
位于MS.Win32.hwndwapper.WndProc(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef)
位于MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate、System.Object、Int32)
位于MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object、System.Delegate、System.Object、Int32、System.Delegate)
位于System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority,System.TimeSpan,System.Delegate,System.Object,Int32)
在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,Int32,IntPtr,IntPtr)
位于MS.Win32.unsafentivemethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
位于System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
位于System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
在System.Windows.Threading.Dispatcher.Run()中
位于System.Windows.Application.RunDispatcher(System.Object)
位于System.Windows.Application.RunInternal(System.Windows.Window)
在System.Windows.Application.Run(System.Windows.Window)中
在ApplicationName.App.Main()处
因此,我猜它与我的一个窗口中的一个图像有关,但不确定是什么;)

以前有没有人见过这个异常,并有解决方案


注意:如果这是相关的,我的安装程序会在必要时将WIC和完整的.NET Framework 4.0加载到目标机器上。

我必须建议/a窗口图标文件可能是
.png
格式,将文件转换为
.jpeg
并重试应该是值得的

请注意,有趣的是,根据我的经验,在看似有缺陷的机器上使用Visual Studio进行调试实际上没有问题

很抱歉,我没有关于这件事的任何参考资料,但这是通过自我调查发现的,因为研究结果不多。我会试着看看现在是否有任何信息,就像前一段时间一样

编辑:


感谢您对同一问题的提示。我发现我在Shell.xaml窗口属性中将Icon属性设置为ICO。当我在VS中运行时,我删除了提供无图标窗口的内容。但是我转到了项目属性并在那里选择了图标(VS发现我的资源文件夹中的图标很酷!)。当应用程序构建EXE时,它包含ICO,令人惊讶的是窗口上现在有相同的图标

您是否100%确定目标计算机具有目标.NET Framework的最新service pack?我这里没有该计算机,但除非我弄错了,.NET Framework引发了异常。错误日志的第二行显示“Framework Version:v4.0.30319”,因此我假设这是已安装的版本。如果它与字体问题有关,您可能希望检查此链接:您可能能够找到它正在使用的图像