We have a C# WPF project (.NET 4.0, Visual Studio 2010). It has been tested on both Windows XP and Windows 7 and seems to work fine, but now I have received reports from two customers on the field (both located in Spain for some reason) who cannot start the software.
Looking at the log file I see that they get "The image format is unrecognized" exception (Caused by: Exception from HRESULT: 0x88982F07).
I have googled on the error and I have found that this seems to be that WPF fails to load the Vista PNG icon on Windows XP. But those reports are a couple of years old, surely Microsoft resolved it by now (?), and in my case it works fine on most XP installations. I really don't want to limit the icon appearance on more recent Windows.
The most common use of our application is on Laptops, and one of the users reported that when he connected his laptop to an external monitor the problem got resolved. And when I asked the other one to test the same thing he had the same result.
So my questions are: Do you know if this problem has been resolved by Microsoft? Do you know why it only happens on some Windows XP instances and how it is related to the monitor? And most importantly, do you know what I could do to make our application more robust to this without changing the icon?
I had the same error today, out of the blue, and only on my development machine. The WPF implementation seems to be still buggy.
If I understand this (article) right, it can occur everywhere ICO files are read. In my case it was while setting an icon for the main application window in XAML:
<Window x:Class="MyApp.MainWindow" Icon="Dashboard.ico" >
The above code failed suddenly, but using a PNG file solved the problem:
<Window x:Class="MyApp.MainWindow" Icon="Dashboard.png" >
I've had a bit of fun with this problem this morning. It turned out that the error was occurring only on XP machines where the colour settings were set to 16 bit, and when I changed it to 32-bit the problem magically disappeared.
This goes for XP (including Embedded) SP3.
this issue has had me pulling my hair off for quite a long time, and I have spent quite a while trying to figure out what was going on so I'll share my conclusions since it might help someone else (possibly even myself in the future) :
this issue appears mainly on windows XP and/or when connecting via remote desktop (especially on windows server). But it is kind of random and impossible to replicate on purpose
those links provide a good explanation as well as a solution/workaround :
http://code.logos.com/blog/2008/08/image_format_error_when_loading_from_a_stream.html
https://github.com/LogosBible/Logos.Utility/blob/master/src/Logos.Utility/IO/RebasedStream.cs
using a png file directly will work, but it has its limitations (for instance, I use .ico files so as to have multiple images depending on the size of the displayed icon and a .png file cannot replace a .ico file for this purpose)
the best answer - and what I ended up doing - is what Joachim said in his comment of the OP's question :
https://social.msdn.microsoft.com/Forums/vstudio/en-US/9e723d51-0e26-4609-8fe1-5e0edcf7385b/setting-windowicon-to-vista-256x256-png-icon-causes-a-fileformatexception?forum=wpf
seems to indicate it'll resolve itself if you don't compress the icon.
– Joachim Isaksson Jan 23 '12 at 12:44
so I looked up in icoFx (that I use for my icon editing) and sure enough :
I simply unchecked this and saved my .ico again (size went from 30Kb up to 286Kb in the process!) and voilà!
problem solved
Related
After updating windows to version 1803 none of the WPF applications on a laptop (Intel hd 500 GPU) work properly anymore (start with a blank window or don't show the GUI at all). I've made a simple test app that only shows one button and it results in an empty window. If I turn off the hardware rendering (according to Software rendering mode - WPF), the application works as expected.
I've tried several versions of the GPU driver including the generic MS one, latest one, latest one recommended by the laptop manufacturer, older ones but all with the same result. The recovery point to the previous version is not available anymore.
The laptop is barely running existing applications so setting the registry not to use the hardware rendering for all the .net applications is not an option due to performance degradation.
Has anyone experienced anything similar, are any other solutions to solving this?
Thanks,
Tomislav
The issue happens because I'm using the laptop with the lid down (I connect remotely to it). This seems to put the GPU to sleep/power down state which messes up the applications that use GPU acceleration. Interestingly desktop and some applications run normally.
Adding a fake display solved the issue (https://forums.lenovo.com/t5/ThinkPad-X-Series-Laptops/Working-with-closed-lid/td-p/1623610, https://superuser.com/questions/1271344/fake-montitor-for-teamviewer-on-laptop-with-closed-lid).
I have also had this issue and have found that if you uninstall and delete the Intel Display Adapter, then let Windows automatically find the default, this issue is resolved.
I have Windows 8.1 on a Virtual Machine (Oracle VirtualBox). I use this machine to develop apps on my windows phone (directly on the phone, not via emulators).
Everything worked fine for a long while and suddenly, out of nowhere, the designer stopped working...
The problem looks like this:
I can add controls, however I cannot see them in the designer, only shows some black square at top-left of the phone designer. (It works fine later on the phone, but I cannot view it in Visual Studio). There are no errors anywhere. It is really annoying and I cannot seem to find any answer so far...
Any ideas?
Thanks,
Keran.
Posted by Varun Mashru on 5/23/2014 at 3:54 AM on Visual Studio Feedback Forum
Surprisingly and fortunately, I found the solution just two days ago.
It is a bit of a bummer but that's what it is.
It has nothing to do with the VS setup or the OS.
The first thing to notice here is that it happens with notebooks only.
The REASON??
Because notebooks do not have completely dedicated GPUs. These GPUs
act as secondary processors for the onboard graphics solution which is
directly connected to the display. Hence they fire up only when
needed.
My notebook is a Dell Inspiron 15 3537 -- Core i5 4200U (Intel HD Graphics
4400 onboard) + AMD Radeon HD 8670M. It has a switchable graphics
solution. Hence the software chooses as to which GPU does the
weight-lifting.
The power settings, when cranked up to the max, indicate that the AMD
GPU must be the one that should take the lead.
And in the case of VS it does not happen properly (Don't know why??).
Maybe the UI components can't decide which GPU processor to choose
or whatever.
So the simple workaround I found was to bring the graphics settings
down by just a notch. Which is selecting the 'Optimize Performance'
option in the Switchable Graphics instead of the 'Maximize Performance'
field in the power plans.
And voila, It works perfectly fine!!!!
Share this with everyone who has freaked out for months on this
issue!! :)
Though the answer from Hassan El-Zarkawy is also useful, the real problem for me was with Oracle Virtual Box...
At some point I have turned on 3D acceleration for the VM. This messed up the designer in the Visual Studio. As soon as I turned it off, everything worked fine, even on the high performance battery setting.
I don't know if it matters, but I also switched to 1 core for the virtual machine, it seems to work better now apparently...
Anyway, thanks for the help.
We have a huge project in WPF .NET 4.0 which should support Windows XP SP3 and above. (hence the use of .NET 4.0) It has no problems whatsoever on Windows 7 and 8/8.1. However we're experiencing major visual issues when running on Windows XP to the point that the application is unusable.
I searched a lot and came across some similar questions such as this one but none of the suggested solutions worked for us.
Here's an screen shot taken on Windows XP SP3:
The odd thing here is that there is clone of "28" TextBlock you see in the screen shot, to the left of it. They have everything in common except their name but the left one is not rendered properly!
And here is how it really looks like (taken on a Windows 8.1 test machine):
Some pages are even worse:
When I remove AllowsTransparency from the main window, it looks like this on XP: (Note that the title bar has no problems any more)
We're really stuck and have no clues about its cause. Any help would be appreciated.
It seems this problem is related to the graphic card. In another VM with a different graphics accelerator we didn't face any major problems. In the problematic test machine, we lowered hardware acceleration to the third level and the problem is gone.
Display Properties -> Settings -> Advanced -> Troubleshoot
Although there are still some small issues with some mouse over animations and we lost the benefits cursor accelerations bring to the table, it's acceptable for us since not much is expected from Windows XP.
We load a C# project out of TFS, click on the solution and it builds fine on XP, but dies on Windows 7, with multiple
Cannot write "C:...\projectName.resources." Parameter is not valid.
and one error that mentioned GDI+. Web searches turn up hits about constructing GIF objects in a program, but little about this problem except suggestions to replace all images with PNG's, with some posts implicating alpha channel problems in the Bitmap class. I tried that approach for TIF's and it made the GDI error go away, but some of the images are animated GIF's that our users are trained on and we don't want to change those. Another suggestion was to replace the Bitmap class with a third party version, which seems kind of drastic and it is not free, so we didn't try it yet.
On 7 the build also fails from the command line, and it fails for GIF's from the XP project or ones new'ed on Win 7 from the designer now.
Is it really the case the VisualStudio 2008 running on Win 7 only
supports PNG's?
But then why would designer let users add a GIF, and then give this error at build time?
The few posts I find are from 2011 and blame the Bitmap class. Looks like a single class could have been straightened out by now, if that is in fact the problem.
I have a .Net application that was originally created in Visual Studio Professional 2005, using the .Net 2.0 framework.
Recently, I have opened the project in Visual C# Express 2010, made some minor changes, and built it using .Net framework 4.0.
Everything works like a charm except for one quite annoying part. When I am running the application on a HP EliteBook 8740w, with a 1920x1200 screen, a group of GUI controls get shuffled around, so that they land on top of eachother. This error does not show up when running on my Windows 7 64 bit workstation with external display of 1900x1080 resolution. Neither does it show when running on a Windows XP laptop with 1024x768 resolution.
I have tried to connect a 1600x1200 external display to the EliteBook, but the error shows up there also.
The controls that get messed up are a set of comboboxes, numericUpAndDowns, and labels, laid out in a table layout container, that in turn is placed on a tab page in a tab page control.
I have tried creating a new tab page control and table layout container from scratch, and then moving the comboboxes etc into the new table layout container, but the error prevails.
I would really appreciate some help in this matter, because I don't know what else to try. I am starting to suspect that there is something wrong with the graphics on the EliteBook, but, then again, everything else renders nicely on its screen.
Thanks,
Fredrik Israelsson
--- Edit ---
Thank you for your quick answers. Before I had a chance to look at them, I think I solved the problem by myself. Stumbled upon a thread about why Visual Studio automatically changes sizes of controls although one has set anchor and dock properties to None. One of the answers mentioned the AutoScaleMode property. I changed AutoScaleMode from Font to None on my main application Window, and no the GUI renders nicely on all my computers.
Thanks again!
/Fredrik Israelsson
I suspect that this is because the two machines have different DPI settings. This is always a pain with Windows Forms.
Here are a few links that might help.
http://msdn.microsoft.com/en-us/library/ms229605.aspx
http://www.sellsbrothers.com/writing/winformsAutoScaling.htm
It could be related to Hardware Acceleration. Is your application a WinForms or a WPF one?
I have faced really odd behaviors when using VS2010 on Win7 64 bit only because it was trying to use Hardware Acceleration when I built the app.
Improving Performance by Changing the Visual Experience
You might have a problem with Hardware Acceleration in VS2010. I had an issue with rendering applications built using WPF because of this.
Give it a try: http://blogs.msdn.com/b/zainnab/archive/2010/06/22/improving-performance-by-changing-the-visual-experience-vstipenv0017.aspx
And if that doesn't fix your issue, go to your video card settings (nvidia or amd catalyst) and do a "reset settings" on the computer where the app doesn't correctly paint itself. Then try again.