Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

COM preview handlers throw 0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL) when SetRect is called during input-synchronous callbacks. This manifests as unhandled exceptions when resizing XLSX/CSV previews.

Changes

  • Wrap SetRect call in PreviewHandlerHost.OnResize with try-catch for HResult 0x8001010D
  • Exception is safely ignored as subsequent resize events will succeed
protected override void OnResize(EventArgs e)
{
    base.OnResize(e);

    try
    {
        var r = ClientRectangle;
        _mCurrentPreviewHandler?.SetRect(ref r);
    }
    catch (COMException ex) when (ex.HResult == unchecked((int)0x8001010D))
    {
        // Transient COM threading issue - next resize will succeed
    }
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Unhandled Exception with XLSX and CSV files</issue_title>
<issue_description>Describe the bug
I have multiple XLSX and CSV documents saved on my Desktop. Twice this evening, I have received exceptions when QuickLooking the files.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to an XLSX or CSV file.
  2. Press the Space Bar to activate QuickLook
  3. The preview is shown, but an unhandled exception report is generated.

Expected behavior
The preview is shown, and there is no unhandled exception.

Desktop (please complete the following information):

  • OS Version: Windows 11 Pro 25H2 (26200.7462)
  • QuickLook Version: 4.3.0 from Github

Screenshots and Exception Log

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x8001010D): An outgoing call cannot be made since the application is dispatching an input-synchronous call. (Exception from HRESULT: 0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL))
   at QuickLook.Plugin.OfficeViewer.IPreviewHandler.SetRect(Rectangle& rect)
   at QuickLook.Plugin.OfficeViewer.PreviewHandlerHost.OnResize(EventArgs e)
   at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
   at System.Windows.Forms.Control.UpdateBounds()
   at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Image

QuickLook.Exception.log

</issue_description>

<agent_instructions>************** Exception Text **************
System.Runtime.InteropServices.COMException (0x8001010D): An outgoing call cannot be made since the application is dispatching an input-synchronous call. (Exception from HRESULT: 0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL))
at QuickLook.Plugin.OfficeViewer.IPreviewHandler.SetRect(Rectangle& rect)
at QuickLook.Plugin.OfficeViewer.PreviewHandlerHost.OnResize(EventArgs e)
at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
at System.Windows.Forms.Control.UpdateBounds()
at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</agent_instructions>

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


💡 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.

Copilot AI changed the title [WIP] Fix unhandled exception with XLSX and CSV files in QuickLook Handle RPC_E_CANTCALLOUT_ININPUTSYNCCALL in OfficeViewer resize Jan 16, 2026
Copilot AI requested a review from emako January 16, 2026 03:30
@emako emako marked this pull request as ready for review January 16, 2026 11:02
Copilot AI review requested due to automatic review settings January 16, 2026 11:02
@emako emako merged commit 32601d2 into master Jan 16, 2026
4 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an unhandled COM exception that occurs when resizing XLSX and CSV file previews. The exception RPC_E_CANTCALLOUT_ININPUTSYNCCALL (0x8001010D) is thrown when SetRect is called on preview handlers during input-synchronous callbacks.

Changes:

  • Added try-catch block around SetRect call in OnResize method to handle transient COM threading exception
  • Exception is safely ignored as subsequent resize events will successfully update the preview handler

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

var r = ClientRectangle;
_mCurrentPreviewHandler?.SetRect(ref r);
}
catch (COMException ex) when (ex.HResult == unchecked((int)0x8001010D))
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The exception variable 'ex' is declared in the catch clause but never used. Consider removing it to avoid the unused variable warning, or use a discard pattern with an underscore if you need to filter by HResult. Change to: catch (COMException) when (...) or catch (COMException _) when (...)

Suggested change
catch (COMException ex) when (ex.HResult == unchecked((int)0x8001010D))
catch (COMException _) when (_.HResult == unchecked((int)0x8001010D))

Copilot uses AI. Check for mistakes.
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.

Unhandled Exception with XLSX and CSV files

2 participants