Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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:

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:


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 nameFile versionFile sizeDateTimePlatform
Presentationcore.dll3.0.6920.40334,218,88002-Sep-201001:32x86
Presentationframework.dll3.0.6920.40335,279,74402-Sep-201001:28x86
Presentationhost.exe4.0.40305.0295,26402-Sep-201001:28x86
Presentationhostdll.dll3.0.6920.4033130,40802-Sep-201001:32x86
Presentationhostproxy.dll4.0.31106.099,17602-Sep-201001:32x86
Windowsbase.dll3.0.6920.40331,249,28002-Sep-201001:32x86
For all supported x64-based versions of Windows Server 2003 and of Windows XP
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll3.0.6920.40333,997,69602-Sep-201000:53x64
Presentationframework.dll3.0.6920.40334,636,67202-Sep-201000:48x64
Presentationhost.exe4.0.31106.0320,35202-Sep-201000:48x64
Presentationhostdll.dll3.0.6920.4033171,36802-Sep-201000:53x64
Presentationhostproxy.dll4.0.31106.0109,92802-Sep-201000:53x64
Windowsbase.dll3.0.6920.40331,110,01602-Sep-201000:53x64
For all supported x86-based versions of Windows Vista Service Pack 2 (SP2) and of Windows Server 2008 Service Pack 2 (SP2)
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll3.0.6920.40334,218,88009-Sep-201010:52x86
Presentationfontcache.exe.configNot Applicable16103-Apr-200921:25Not Applicable
Wpfgfx_v0300.dll3.0.6920.40031,736,02417-Jun-200908:03x86
Presentationframework.dll3.0.6920.40335,279,74409-Sep-201010:52x86
Presentationhostdll.dll3.0.6920.4033130,40809-Sep-201010:52x86
Windowsbase.dll3.0.6920.40331,249,28009-Sep-201010:52x86
For all supported x64-based versions of Windows Vista SP2 and of Windows Server 2008 SP2
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll3.0.6920.40333,997,69609-Sep-201010:52x64
Presentationfontcache.exe.configNot Applicable16103-Apr-200920:58Not Applicable
Wpfgfx_v0300.dll3.0.6920.40032,254,16817-Jun-200908:03x64
Presentationframework.dll3.0.6920.40334,636,67209-Sep-201010:52x64
Presentationhostdll.dll3.0.6920.4033171,36809-Sep-201010:52x64
Windowsbase.dll3.0.6920.40331,110,01609-Sep-201010:52x64
For all supported x86-based version of Windows 7
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll3.0.6920.50124,218,88011-Sep-201001:29x86
Presentationfontcache.exe.configNot Applicable16110-Jun-200921:14Not Applicable
Wpfgfx_v0300.dll3.0.6920.49021,736,53610-Jun-200921:14x86
Presentationframework.dll3.0.6920.50125,279,74411-Sep-201001:29x86
Presentationhostdll.dll3.0.6920.5012130,40811-Sep-201001:29x86
Presentationhost.exe4.0.31106.0295,26411-Sep-201001:29x86
Presentationhostproxy.dll4.0.31106.099,17611-Sep-201001:29x86
Windowsbase.dll3.0.6920.50121,253,37611-Sep-201001:29x86
For all supported x64-based versions of Windows 7 and of Windows Server 2008 R2
File nameFile versionFile sizeDateTimePlatform
Presentationcore.dll3.0.6920.50123,997,69611-Sep-201001:28x64
Presentationfontcache.exe.configNot Applicable16110-Jun-200920:30Not Applicable
Wpfgfx_v0300.dll3.0.6920.49022,255,17610-Jun-200920:30x64
Presentationframework.dll3.0.6920.50124,636,67211-Sep-201001:28x64
Presentationhostdll.dll3.0.6920.5012171,36811-Sep-201001:28x64
Presentationhost.exe4.0.31106.0320,35211-Sep-201001:28x64
Presentationhostproxy.dll4.0.31106.0109,92811-Sep-201001:28x64
Windowsbase.dll3.0.6920.50121,114,11211-Sep-201001:28x64

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


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

↑ Back to the top


Keywords: kbnotautohotfix, kbhotfixdev, kbqfe, kbfix, kbexpertiseadvanced, kbsurveynew, atdownload, kb

↑ Back to the top

Article Info
Article ID : 2276690
Revision : 1
Created on : 1/7/2017
Published on : 5/17/2013
Exists online : False
Views : 236