Link to home
Start Free TrialLog in
Avatar of rturney
rturneyFlag for United States of America

asked on

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

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
Avatar of BitRunner303
BitRunner303

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.
Avatar of rturney

ASKER

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.
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.
Avatar of rturney

ASKER

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.
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.
Avatar of rturney

ASKER

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.
Avatar of rturney

ASKER

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.
Avatar of rturney

ASKER

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!
Avatar of rturney

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of BitRunner303
BitRunner303

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rturney

ASKER

Thanks BitRunner303.  That makes perfect sense.  Now I know the reasons why I was having those problems.  
Best regards,
-Bob