A "COMException" exception causes a .NET Framework 3.5 SP1-based WPF application to crash if the application loads and unloads the application domains frequently

Symptoms

Consider the following scenario:

  • You run a Microsoft .NET Framework 3.5 Service Pack 1 (SP1)-based Windows Presentation Foundation (WPF) application.

  • The WPF application uses the hardware rendering pipeline.

  • The application loads and unloads many application domains that contain one or more custom WPF add-in components.

In this scenario, the application encounters a System.Runtime.InteropServices.COMException exception, and then the application crashes.

Resolution

Hotfix information

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

To download this hotfix from the MSDN Code Gallery, visit the following Microsoft website:

http://code.msdn.microsoft.com/KB2276690
Note The MSDN Code Gallery displays the languages for which the hotfix is available. If you do not see your language listed, it is because the Code Gallery resource page is not available for that language.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft website:

http://support.microsoft.com/contactus/?ws=support



Prerequisites

To apply this hotfix, you must have the .NET Framework 3.5 Service Pack 1 (SP1) installed. 

Restart requirement

You do not have to restart the computer after you apply this hotfix.

Hotfix replacement information


This hotfix does not replace any other hotfix.

File Information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.


For all supported x86-based versions of Windows Server 2003 and of Windows XP

File name

File version

File size

Date

Time

Platform

Presentationcore.dll

3.0.6920.4033

4,218,880

02-Sep-2010

01:32

x86

Presentationframework.dll

3.0.6920.4033

5,279,744

02-Sep-2010

01:28

x86

Presentationhost.exe

4.0.40305.0

295,264

02-Sep-2010

01:28

x86

Presentationhostdll.dll

3.0.6920.4033

130,408

02-Sep-2010

01:32

x86

Presentationhostproxy.dll

4.0.31106.0

99,176

02-Sep-2010

01:32

x86

Windowsbase.dll

3.0.6920.4033

1,249,280

02-Sep-2010

01:32

x86

For all supported x64-based versions of Windows Server 2003 and of Windows XP

File name

File version

File size

Date

Time

Platform

Presentationcore.dll

3.0.6920.4033

3,997,696

02-Sep-2010

00:53

x64

Presentationframework.dll

3.0.6920.4033

4,636,672

02-Sep-2010

00:48

x64

Presentationhost.exe

4.0.31106.0

320,352

02-Sep-2010

00:48

x64

Presentationhostdll.dll

3.0.6920.4033

171,368

02-Sep-2010

00:53

x64

Presentationhostproxy.dll

4.0.31106.0

109,928

02-Sep-2010

00:53

x64

Windowsbase.dll

3.0.6920.4033

1,110,016

02-Sep-2010

00:53

x64

For all supported x86-based versions of Windows Vista Service Pack 2 (SP2) and of Windows Server 2008 Service Pack 2 (SP2)

File name

File version

File size

Date

Time

Platform

Presentationcore.dll

3.0.6920.4033

4,218,880

09-Sep-2010

10:52

x86

Presentationfontcache.exe.config

Not Applicable

161

03-Apr-2009

21:25

Not Applicable

Wpfgfx_v0300.dll

3.0.6920.4003

1,736,024

17-Jun-2009

08:03

x86

Presentationframework.dll

3.0.6920.4033

5,279,744

09-Sep-2010

10:52

x86

Presentationhostdll.dll

3.0.6920.4033

130,408

09-Sep-2010

10:52

x86

Windowsbase.dll

3.0.6920.4033

1,249,280

09-Sep-2010

10:52

x86

For all supported x64-based versions of Windows Vista SP2 and of Windows Server 2008 SP2

File name

File version

File size

Date

Time

Platform

Presentationcore.dll

3.0.6920.4033

3,997,696

09-Sep-2010

10:52

x64

Presentationfontcache.exe.config

Not Applicable

161

03-Apr-2009

20:58

Not Applicable

Wpfgfx_v0300.dll

3.0.6920.4003

2,254,168

17-Jun-2009

08:03

x64

Presentationframework.dll

3.0.6920.4033

4,636,672

09-Sep-2010

10:52

x64

Presentationhostdll.dll

3.0.6920.4033

171,368

09-Sep-2010

10:52

x64

Windowsbase.dll

3.0.6920.4033

1,110,016

09-Sep-2010

10:52

x64

For all supported x86-based version of Windows 7

File name

File version

File size

Date

Time

Platform

Presentationcore.dll

3.0.6920.5012

4,218,880

11-Sep-2010

01:29

x86

Presentationfontcache.exe.config

Not Applicable

161

10-Jun-2009

21:14

Not Applicable

Wpfgfx_v0300.dll

3.0.6920.4902

1,736,536

10-Jun-2009

21:14

x86

Presentationframework.dll

3.0.6920.5012

5,279,744

11-Sep-2010

01:29

x86

Presentationhostdll.dll

3.0.6920.5012

130,408

11-Sep-2010

01:29

x86

Presentationhost.exe

4.0.31106.0

295,264

11-Sep-2010

01:29

x86

Presentationhostproxy.dll

4.0.31106.0

99,176

11-Sep-2010

01:29

x86

Windowsbase.dll

3.0.6920.5012

1,253,376

11-Sep-2010

01:29

x86

For all supported x64-based versions of Windows 7 and of Windows Server 2008 R2

File name

File version

File size

Date

Time

Platform

Presentationcore.dll

3.0.6920.5012

3,997,696

11-Sep-2010

01:28

x64

Presentationfontcache.exe.config

Not Applicable

161

10-Jun-2009

20:30

Not Applicable

Wpfgfx_v0300.dll

3.0.6920.4902

2,255,176

10-Jun-2009

20:30

x64

Presentationframework.dll

3.0.6920.5012

4,636,672

11-Sep-2010

01:28

x64

Presentationhostdll.dll

3.0.6920.5012

171,368

11-Sep-2010

01:28

x64

Presentationhost.exe

4.0.31106.0

320,352

11-Sep-2010

01:28

x64

Presentationhostproxy.dll

4.0.31106.0

109,928

11-Sep-2010

01:28

x64

Windowsbase.dll

3.0.6920.5012

1,114,112

11-Sep-2010

01:28

x64

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Workaround

To work around this issue, disable the hardware rendering pipeline, and then enable the software rendering pipeline.

To disable the hardware rendering pipeline, and to enable the software rendering pipeline, use one of the following methods:

  • Set the System.Windows.Interop.RenderMode enumeration.

    The following is some example code that sets the System.Windows.Interop.RenderMode enumeration to enable the software rendering pipeline when a WPF window is loaded:

    private void OnLoaded(object sender, EventArgs e)
    {
    System.Windows.Interop.HwndSource hwndSource = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
    System.Windows.Interop.HwndTarget hwndTarget = hwndSource.CompositionTarget;

    hwndTarget.RenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
    }
  • Set the DisableHWAcceleration registry key.

    Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

    322756 How to back up and restore the registry in Windows

    Warning This method disables hardware rendering pipeline for all WPF applications on the computer. Therefore, the method is not encouraged usually except when the customers control the environments and do not mind the effect for all WPF applications.

    1. Click Start, click Run, type regedit, and then press ENTER.

    2. Locate and then click the following registry subkey:

      HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics

    3. Set the value of the DisableHWAcceleration registry entry to 1.

      Note If the DisableHWAcceleration registry entry does not exist, right-click the registry subkey, point to New, and then click String Value to create a new registry entry. Type DisableHWAcceleration for the name of the new registry entry, double-click DisableHWAcceleration, and then change the DisableHWAcceleration value data to 1.

    4. Exit Registry Editor.

More Information

For more information about the software rendering pipeline, visit the following Microsoft Developer Network (MSDN) website:

General information about the software rendering pipeline

For more information about the registry settings of WPF rendering, visit the following MSDN website:

General information about the registry settings of WPF rendering

For more information about the System.Windows.Interop.RenderMode enumeration, visit the following MSDN website:

General information about the "System.Windows.Interop.RenderMode" enumeration

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×