Solved

C# Application crashes when WinXP Appearance set to "Windows Classic"

Posted on 2008-06-11
11
1,766 Views
Last Modified: 2013-12-17
A mysterious thing is happening when the users of an application I am developing runs under Windows XP with its appearance setting set to "Windows Classic Style".  The application loads okay, but when a user double-clicks a thumbnail picture to view the picture full size (in a separate form), the application crashes.  Here's some of the long error message:

System.Runtime.InteropServices.COMException (0x800A03EA): No image has been specified.
Unable to display image at
System.RuntimeType.Forward CallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] a WrapperTypes, MessageData& at
ImgeditLibCtl._DImgEdit.Display() at
AxImgeditLibCtl.AxImgEdit.Display() at
EView2.formViewDwg.formViewDwg_SizeChanged(Objectsender, EventArgs e) at
System.Windows.Forms.Control.OnSizeChanged(EventArgs e) ...

The image control is a COM instead of a .Net component.

For comparison, I set my Appearance settings to "Windows Classic Style" and ran the application.  Instead of crashing, mine didn't display the picture and left a blank image, but it didn't crash.

When I change my Appearance setting back to "Windows XP Style" everything works fine.

This has left me clueless as to what is wrong.  I hope someone has an idea to explain why this is happening.

Thanks,
-Bob
0
Comment
Question by:rturney
  • 7
  • 3
11 Comments
 
LVL 3

Expert Comment

by:BitRunner303
ID: 21762866
One thing you might want to try is look at your Program.cs for some lines that say:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Try commenting one or both of those out and see if the same behavior exists.
0
 

Author Comment

by:rturney
ID: 21763095
Thank you very much for your suggestion.  I found the code you referred to and commented out the first line.  Same response on my machine - no picture.  Then I commented out both lines and still no picture.  I tried all the combinations but I still can't get the picture to show.

The application uses the old Kodak Imaging control (COM).  I have two of these controls: one on the main form (Thumbnail size) and a second one on the viewing form.  To view the picture, you double-click the thumbnail (main form) and the file path is passed to the viewing form in the constructor.
0
 
LVL 3

Expert Comment

by:BitRunner303
ID: 21763265
Sounds like it's specific to the Kodak Imaging Control (from what I'm reading it's an older control that's no longer supported in XP, at least I don't have it on my setup) Is the picture not showing up in the second form or in the first or both?  

Something I'd check for first of all is make absolutely sure that the filename is being corrently passed to the control.  Do some breakpoint debugging and check the state of the parameter to make sure the string is not null or blank.  I imagine that's not the case though so next thing...

Make sure that you followed all of these steps to install the control:
http://www.foxite.com/archives/kodak-image-controls-0000012481.htm

Lastly, I have to ask, what's the need to have it on an old COM imaging control that's no longer supported when you could use the native PictureBox control in .NET?  You can do scaling with it easily so you should be able to do exactly what you want with showing a thumbnail and a full sized image.
0
 

Author Comment

by:rturney
ID: 21763592
Yes, MS and Kodak could not come to an agreement for its use on XP so MS dropped it.  It was on all the Win2000 releases.  I tried not to use the old Kodak Imaging COM, but I have to work with *.tif files and the PictureBox control will not accept tifs.  I worked with it a little bit, but you had to convert the tif to a bitmap and then deal with the scaling issues.  It was like a blank slate that needed a lot of functionality to get close to the Kodak imager.  I tried to find a similar modern .Net tif viewer but they are very expensive $1,000-$1,500.  Surprisingly, I have had zero problems with it until we ran the application on the machine with the Windows Appearance set to "Classic".

Thanks for the other suggestion about installing the control.  To my knowledge, none of the steps listed have been performed on these machines.  This is something I need to look into further.  Thanks for shedding light on this problem.
0
 
LVL 8

Expert Comment

by:unmeshdave
ID: 21764025
this is because of the bug in windows when you are loading 2 versions of Comctl32.dll at the same time. If you are using windows XP SP2, download and install SP3 for XP as it has solved this problem of windows.

Hope this helps.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:rturney
ID: 21764199
Thanks for that piece of information.  

I just talked to our IT guy and he said we can't install SP3 until he says so.  But one of the users is secretly running SP3 and he is not having any issues.  Everyone else is running SP2 and only two out of those eight are having the problems.  I am running SP2 and am not having issues.  I am trying to find out what is common about the two users having the issues.  If SP3 fixes the problem, I won't know until IT lets us install it.  But I am anxious to try it.
0
 

Author Comment

by:rturney
ID: 21764562
I'm sorry BitRunner303, I didn't answer your question.  The main form with the thumbnail does acquire and show the image.  But the second form, the image viewer, does not acquire the image.  The path for the image is passed through the second form's constructor.
0
 

Author Comment

by:rturney
ID: 21773024
The two computers that are having this problem did not have the Kodak dlls and OCXs.  I took care of that, but it didn't help.  Now IT wants to rename the "local settings" folder to "local settings old" and reboot.  This apparently forces windows to rebuild the local settings.  This took care of a problematic computer that was refusing to install one of my .net apps.  I don't know if it will help for this problem though.  And I still won't know if SP3 will fix this until IT lets us install SP3.  But only one user has SP3 now and the rest of us have SP2.  Four of us using SP2 are not having any issues!
0
 

Author Comment

by:rturney
ID: 21778322
I have found out what was causing the problem.  The second form's height and width commands were in the form's constructor.  I moved them to the Form_Load event and the problems are gone.  I am not sure why the height and width were not recognized when they were in the constructor and were recognized when they were in the Form_Load event?
Any explanation would be appreciated.
0
 
LVL 3

Accepted Solution

by:
BitRunner303 earned 500 total points
ID: 21793848
Here's the reason for your 2nd Form problems that you explained in the previous comment.

In a .NET 2.0/3.0/3.5 WinForm you'll have your form broken down into essentially 2 files, Form2.cs and Form2.Designer.cs.  The constructor in a form usually calls a method InitializeComponents() which is auto-generated by the GUI designer in the Form2.Designer.cs.  That's where your actual components were built.  So, take a look at the snippet.  In this example, if you called a Width/Height change for pictureBox1 in the constructor, you'd probably throw up an exception since pictureBox1 doesn't exist until it's created in InitializeComponents.  If you called a Width/Height in the form itself it wouldn't happen b/c this.ClientSize = new System.Drawing.Size(292, 266) is getting called from the auto-generated code from the designer.  The Load event is actually done after InitializeComponents is called, so it's the best place to do your changes.

If you're working on .NET 1.1/1.0 you're essentially dealing with the same they just don't split it out into an extra .Designer.cs file for code separation.
Form2.cs:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;
 

namespace WindowsFormsApplication1

{

    public partial class Form2 : Form

    {

        public Form2()

        {

            InitializeComponent();

        }
 

        private void Form2_Load(object sender, EventArgs e)

        {
 

        }

    }

}
 

Form2.Designer.cs:

namespace WindowsFormsApplication1

{

    partial class Form2

    {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.IContainer components = null;
 

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

        protected override void Dispose(bool disposing)

        {

            if (disposing && (components != null))

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }
 

        #region Windows Form Designer generated code
 

        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            this.pictureBox1 = new System.Windows.Forms.PictureBox();

            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

            this.SuspendLayout();

            // 

            // pictureBox1

            // 

            this.pictureBox1.Location = new System.Drawing.Point(13, 13);

            this.pictureBox1.Name = "pictureBox1";

            this.pictureBox1.Size = new System.Drawing.Size(267, 241);

            this.pictureBox1.TabIndex = 0;

            this.pictureBox1.TabStop = false;

            // 

            // Form2

            // 

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.ClientSize = new System.Drawing.Size(292, 266);

            this.Controls.Add(this.pictureBox1);

            this.Name = "Form2";

            this.Text = "Form2";

            this.Load += new System.EventHandler(this.Form2_Load);

            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

            this.ResumeLayout(false);
 

        }
 

        #endregion
 

        private System.Windows.Forms.PictureBox pictureBox1;

    }

}

Open in new window

0
 

Author Closing Comment

by:rturney
ID: 31466268
Thanks BitRunner303.  That makes perfect sense.  Now I know the reasons why I was having those problems.  
Best regards,
-Bob
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now