Skip to content

Fix desktop composition error (HRESULT:0x80263001) by ensuring it's always enabled on Windows 8+#1011

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-desktop-composition-issue
Closed

Fix desktop composition error (HRESULT:0x80263001) by ensuring it's always enabled on Windows 8+#1011
Copilot wants to merge 2 commits intomainfrom
copilot/fix-desktop-composition-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 21, 2025

Problem

Users were encountering the error "操作无法完成,因为已禁用桌面合成。(异常来自 HRESULT:0x80263001)" (The operation cannot be completed because desktop composition is disabled. Exception from HRESULT: 0x80263001) when connecting via RDP.

According to Microsoft documentation, desktop composition has been always enabled since Windows 8 and cannot be turned off. However, the application was attempting to disable it in some scenarios or not enabling it in others, causing compatibility issues with modern Windows systems.

Root Cause

The code had three issues:

  1. Auto performance mode: Desktop composition flag was not set, relying on default behavior
  2. Low performance mode: Attempted to disable desktop composition by setting AllowDesktopComposition = 0
  3. Default RDP configuration: AllowDesktopComposition defaulted to 0 (disabled)

Solution

This PR ensures desktop composition is always enabled regardless of display performance settings:

Changes Made

  1. AxMsRdpClient09Host.xaml.cs (RdpInitPerformance method)

    • Always set the desktop composition performance flag (0x00000100) before applying other display performance settings
    • Removed redundant flag setting from Middle and High performance modes since it's now set globally
    • Added reference comment to Microsoft documentation
  2. RDP.cs (ToRdpConfig method)

    • Set AllowDesktopComposition = 1 before the switch statement to ensure it applies to all performance modes
    • Removed individual assignments from Low, Middle, and High cases
    • Added reference comment to Microsoft documentation
  3. RdpConfig.cs

    • Changed default value of AllowDesktopComposition from 0 to 1
    • Added XML documentation explaining that desktop composition is always enabled on Windows 8+

Testing

The changes align the application behavior with Windows 8+ requirements where desktop composition cannot be disabled. This prevents the HRESULT 0x80263001 error while maintaining proper display performance settings for each mode:

  • Auto mode: Desktop composition enabled with automatic detection
  • Low mode: Desktop composition enabled with other visual effects disabled
  • Middle mode: Desktop composition and font smoothing enabled
  • High mode: All visual effects enabled including desktop composition

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>{已禁用桌面合成} 操作无法完成,因为已禁用桌面合成。 (异常来自 HRESULT:0x80263001)</issue_title>
<issue_description>

Details

Environment

Component Version
1Remote(Store) 1.1.1.2(Built at: 2025-05-24T15:21:07.359+08:00)(Microsoft store)
.NET Framework .NET Framework 4.8
CLR 4.0.30319.42000
OS Windows 10 Pro 64-bits 10.0.26200.0 (2009) build 26200

Error Info

{已禁用桌面合成} 操作无法完成,因为已禁用桌面合成。 (异常来自 HRESULT:0x80263001)

Stack Trace

   在 Standard.NativeMethods.DwmExtendFrameIntoClientArea(IntPtr hwnd, MARGINS& pMarInset)
   在 System.Windows.Shell.WindowChromeWorker._ExtendGlassFrame()
   在 System.Windows.Shell.WindowChromeWorker._UpdateFrameState(Boolean force)
   在 System.Windows.Shell.WindowChromeWorker._HandleDwmCompositionChanged(WM uMsg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Shell.WindowChromeWorker._WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Recent Log

[T:001][09:30:38.089]	`Warning`		[(InvokeMethod:0)]	RDP(R510-CCCVPN-RPA-50) exit with error code 3(你的远程桌面服务会话已结束。
远程计算机正在重新启动。)
[T:001][09:30:38.103]	`Warning`		[(RaiseOnOnDisconnected:0)]	RDP Host: Call ReConn
[T:001][09:30:39.217]	`Warning`		[(InvokeMethod:0)]	RDP(R510-CCCVPN-RPA-50) exit with error code 3(你的远程桌面服务会话已结束。
远程计算机正在关闭。)
[T:001][10:38:38.748]	`Warning`		[(RaiseEventImpl:0)]	RDP Host: Call ReConn
[T:001][10:41:31.256]	`Fatal`		[(TryCatchWhen:0)]	
> System.Runtime.InteropServices.COMException (0x80263001): {已禁用桌面合成} 操作无法完成,因为已禁用桌面合成。 (异常来自 HRESULT:0x80263001)
   在 Standard.NativeMethods.DwmExtendFrameIntoClientArea(IntPtr hwnd, MARGINS& pMarInset)
   在 System.Windows.Shell.WindowChromeWorker._ExtendGlassFrame()
   在 System.Windows.Shell.WindowChromeWorker._UpdateFrameState(Boolean force)
   在 System.Windows.Shell.WindowChromeWorker._HandleDwmCompositionChanged(WM uMsg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Shell.WindowChromeWorker._WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
> StackTrace:    在 Standard.NativeMethods.DwmExtendFrameIntoClientArea(IntPtr hwnd, MARGINS& pMarInset)
   在 System.Windows.Shell.WindowChromeWorker._ExtendGlassFrame()
   在 System.Windows.Shell.WindowChromeWorker._UpdateFrameState(Boolean force)
   在 System.Windows.Shell.WindowChromeWorker._HandleDwmCompositionChanged(WM uMsg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Shell.WindowChromeWorker._WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

</issue_description>

<agent_instructions>1. 阅读并分析 issue 中描述问题的产生原因
2. 分析解决方案,若是本软件代码问题则尝试解决
3. 回到issue中用用户所用的语言(中文、英文、日文等)向用户回复。</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@VShawn Desktop composition should always be enabled. https://learn.microsoft.com/en-us/windows/win32/dwm/wm-dwmcompositionchanged

Fixes #1010


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Enable desktop composition flag (0x00000100) for all display performance modes in RdpInitPerformance
- Set AllowDesktopComposition = 1 for all display performance modes in ToRdpConfig
- Change default value of AllowDesktopComposition from 0 to 1 in RdpConfig
- Add comments referencing Microsoft documentation about desktop composition being always enabled on Windows 8+

This fixes the error "操作无法完成,因为已禁用桌面合成。(HRESULT:0x80263001)" that occurs when desktop composition is disabled.

Co-authored-by: VShawn <10143738+VShawn@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix desktop composition error on operation completion Fix desktop composition error (HRESULT:0x80263001) by ensuring it's always enabled on Windows 8+ Oct 21, 2025
Copilot AI requested a review from VShawn October 21, 2025 03:17
Copy link
Copy Markdown
Member

@VShawn VShawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will not fix the issue

@VShawn VShawn marked this pull request as ready for review October 22, 2025 12:02
@VShawn VShawn closed this Oct 22, 2025
@VShawn VShawn deleted the copilot/fix-desktop-composition-issue branch October 22, 2025 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{已禁用桌面合成} 操作无法完成,因为已禁用桌面合成。 (异常来自 HRESULT:0x80263001)

2 participants