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

Closed
opened 2026-03-13 13:02:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/1Remote/1Remote/pull/1011
Author: @Copilot
Created: 10/21/2025
Status: Closed

Base: mainHead: copilot/fix-desktop-composition-issue


📝 Commits (2)

  • ea9c00f Initial plan
  • e265bfe Fix desktop composition to always be enabled on Windows 8+

📊 Changes

3 files changed (+13 additions, -6 deletions)

View changed files

📝 Ui/Model/Protocol/RDP.cs (+3 -3)
📝 Ui/Utils/RdpFile/RdpConfig.cs (+5 -1)
📝 Ui/View/Host/ProtocolHosts/AxMsRdpClient09Host.xaml.cs (+5 -2)

📄 Description

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>

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 1Remote/1Remote#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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/1Remote/1Remote/pull/1011 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 10/21/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/fix-desktop-composition-issue` --- ### 📝 Commits (2) - [`ea9c00f`](https://github.com/1Remote/1Remote/commit/ea9c00f2d11a511a70e1612f60da4055f5fc7026) Initial plan - [`e265bfe`](https://github.com/1Remote/1Remote/commit/e265bfe47759158a12bf097dfbade705c4c4eee7) Fix desktop composition to always be enabled on Windows 8+ ### 📊 Changes **3 files changed** (+13 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Ui/Model/Protocol/RDP.cs` (+3 -3) 📝 `Ui/Utils/RdpFile/RdpConfig.cs` (+5 -1) 📝 `Ui/View/Host/ProtocolHosts/AxMsRdpClient09Host.xaml.cs` (+5 -2) </details> ### 📄 Description ## 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](https://learn.microsoft.com/en-us/windows/win32/dwm/wm-dwmcompositionchanged), 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] <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> ---- *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) ``` </details> </issue_description> <agent_instructions>1. 阅读并分析 issue 中描述问题的产生原因 2. 分析解决方案,若是本软件代码问题则尝试解决 3. 回到issue中用用户所用的语言(中文、英文、日文等)向用户回复。</agent_instructions> ## Comments on the Issue (you are @copilot in this section) <comments> <comment_new><author>@VShawn</author><body> Desktop composition should always be enabled. https://learn.microsoft.com/en-us/windows/win32/dwm/wm-dwmcompositionchanged</body></comment_new> </comments> </details> Fixes 1Remote/1Remote#1010 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-13 13:02:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#3861
No description provided.