C# WinForm程序中因手贱偷懒,程序所有Ico文件只含有256x256大小,导致编译后的程序在WinXp下运行时报告unhandled exception,如图:
QQ截图20120716181737.png

若未在全局Try+Catch异常,则会在系统日志中生成以下日志:

Application: DiffFinder.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Reflection.TargetInvocationException
Stack:
   at System.RuntimeMethodHandle._SerializationInvoke(System.IRuntimeMethodInfo, System.Object, System.SignatureStruct ByRef, System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)
   at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(System.Object, System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)
   at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(System.Runtime.Serialization.ObjectHolder)
   at System.Runtime.Serialization.ObjectManager.DoFixups()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(System.Runtime.Remoting.Messaging.HeaderHandler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser, Boolean, Boolean, System.Runtime.Remoting.Messaging.IMethodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(System.IO.Stream, System.Runtime.Remoting.Messaging.HeaderHandler, Boolean, Boolean, System.Runtime.Remoting.Messaging.IMethodCallMessage)
   at System.Resources.ResourceReader.DeserializeObject(Int32)
   at System.Resources.ResourceReader._LoadObjectV2(Int32, System.Resources.ResourceTypeCode ByRef)
   at System.Resources.ResourceReader.LoadObjectV2(Int32, System.Resources.ResourceTypeCode ByRef)
   at System.Resources.ResourceReader.LoadObject(Int32, System.Resources.ResourceTypeCode ByRef)
   at System.Resources.RuntimeResourceSet.GetObject(System.String, Boolean, Boolean)
   at System.Resources.RuntimeResourceSet.GetObject(System.String, Boolean)
   at System.Resources.ResourceManager.GetObject(System.String, System.Globalization.CultureInfo, Boolean)
   at System.Resources.ResourceManager.GetObject(System.String)
   at DiffFinder.frmDiffFinder.InitializeComponent()
   at DiffFinder.frmDiffFinder..ctor()
   at DiffFinder.Program.Main()


有关更多信息,请参阅在 http://go.microsoft.com/fwlink/events.asp 的帮助和支持中心。

解决方案:
添加各种大小尺寸到Ico文件中后编译,异常消失。

Fuck WinXP!

标签: winform, winxp, c#

添加新评论