0
votes

I've made this program which works fine in Windows 7, but it doesn't seem to work in Windows XP, as it crashed right away with a 'Program has closed bla bla send error report' message from Windows. After some googling I found a solution to get myself an exceptionlog in the Event Log. This is the result:

Edit: new exception log (with unhandled exception filter)

Exception: Het doel van een aanroep heeft een uitzondering veroorzaakt. bij System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context) bij System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context) bij System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context) bij System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context) bij System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder) bij System.Runtime.Serialization.ObjectManager.DoFixups()
bij System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) bij System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) bij System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
bij System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode) bij System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode) bij System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString) bij System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase) bij System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream) bij System.Resources.ResourceManager.GetObject(String name) bij STREDIT.frmMain.InitializeComponent() bij STREDIT.frmMain..ctor()
bij STREDIT.Program.Main()

I've found the place where it crashed:

this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); // Here
this.MainMenuStrip = this.menuStrip1;
this.MinimumSize = new System.Drawing.Size(726, 220);

Does anyone have an idea why this happens?

Thanks in advance

3
That is just the stack trace. If you want the full exception I would suggest using AppDomain.UnhandledException to get the exception that crashes your program. msdn.microsoft.com/en-us/library/… - Will
I've done that now, High. I don't see any difference though. - Diamondo25
You forgot to log the exception's InnerException property. Use e.ExceptionObject.ToString() in your event handler. Shooting off the hip, you probably used an icon format that XP doesn't support. - Hans Passant
It was indeed the icon type. Windows XP didn't like it. Thanks Hans! - Diamondo25

3 Answers

1
votes

Icon type correct or not, there is a solution to handle it correctly:

  • put the icons into Assembly's resource file (if you haven't)
  • access the icon like this:

    this.Icon = global::AEM.UI.Properties.Resources.your_icon_name;
    
1
votes

Windows XP does not support PNG icons. Create a non-PNG ico for the application, and the application will run fine :).

0
votes

I had exactly the same symptoms on Win7 (with a ICO image) and I found a workaround : add a small delay before the InitializeComponent() for let time to the app to load resources.

public MyForm()
{
    Thread.Sleep(100); // delay for loading ressources

    InitializeComponent();
}

In my case is was not caused by the image format because it worked fine with that image during months of development. It was really caused by the resources loader.