System.Windows.Markup.XamlParseException with WPF application in Visual Studio 2015

I recently had a customer report that sample WPF code from the Chapter 10: Resources chapter of the APRESS book ‘Pro WPF in C#’ was throwing an exception when compiled and run only under the Visual Studio 2015 debugger: System.Windows.Markup.XamlParseException occurred  HResult=-2146233087  LineNumber=8  LinePosition=32  Message=’Provide value on ‘System.Windows.Baml2006.TypeConverterMarkupExtension’ threw an exception.’ Line number ‘8’ and line…

0

WPF Render Thread Failures

A common problem developers face with WPF applications is how to deal with exceptions related to render thread failures. You might get reports from users indicating their application throws an exception like one of the following. System.Runtime.InteropServices.COMException: UCEERR_RENDERTHREADFAILURE (Exception from HRESULT: 0x88980406)   at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()   at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)   at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget)   at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)  …

6

Using a Custom AutomationPeer in Cases of UIA Related Performance Degradation

Summary The Microsoft User Interface Automation (UIA) framework is great for helping automate testing and provide accessibility services for applications generally, but there are some cases where it may be disadvantageous for a client with very deeply nested UI components, since UIA requests can become taxing under those circumstances, degrading performance particularly.  This may even…


Using Theme APIs to draw the border of a control

In this article, we will take a look at using the Theme APIs to draw the border of a control using the current visual style. Each window class is responsible for defining its appearance, which includes the client and non-client portions of the window. A window’s border is typically part of its non-client area. Windows…


Printing from a Windows Service

It is often desirable to print a document to a printer from your Windows service.  While calling the Windows Win32 GDI APIs to send a document to the printer is supported, there are some important considerations to take into account, such as which user account the service is running under, and whether that user has…

3

Debugging a GDI Resource Leak

One of the most common graphics-related problems we see is a “GDI leak” (or, simply the usage of too many GDI objects), which will eventually cause rendering problems, errors, and/or performance problems. Some things need to be defined and explained before I talk about how we debug these problems.    –Definitions– GDI Objects are resources…


Using Direct2D from a service in C#

It is often desirable to create graphical images on disk from a service context.  For example, some server applications need to render images and send back the generated bitmaps to users connected through web clients. One example would be an ASP.NET web application which needs to generate user profile pictures on the fly. We have…

3

Ways to capture the screen

Capturing the screen (or put another way, creating an in-memory copy of the image currently being displayed on the screen, for re-display, printing, or later saving) is a task with many different solutions.  I’ll try to enumerate the possibilities below.  This isn’t a perfect or complete list, but it covers the best supported ways, and lists some…


Troubleshooting CreateWindowEx failures

Several years back, my team was handling multiple issues where Windows Forms application would throw an exception while trying to create a new form, control, etc. While the description string that Windows Forms included in the exception (“Error creating window handle.”) indicated that a call to CreateWindowEx failed, the exception did not provide any information…


Debugging Windows Forms Application Hangs During SystemEvents.UserPreferenceChanged

Hi Everyone, One of the most common issues we debug related to Windows Forms applications is when an application becomes unresponsive due to the SystemEvents.UserPreferenceChanged event. This blog to explain what is actually occurring, and how to find and fix the culprit. The reason this occurs and the solution is explained in KnowledgeBase article 943139. Windows…

4