Skip to content

Handle RPC_E_CANTCALLOUT_ININPUTSYNCCALL in OfficeViewer resize#1862

Merged
emako merged 2 commits into
masterfrom
copilot/fix-xlsx-csv-exception
Jan 16, 2026
Merged

Handle RPC_E_CANTCALLOUT_ININPUTSYNCCALL in OfficeViewer resize#1862
emako merged 2 commits into
masterfrom
copilot/fix-xlsx-csv-exception

Conversation

Copilot AI commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

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.

…nResize

Co-authored-by: emako <24737061+emako@users.noreply.github.com>
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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))

This comment was marked as abuse.

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

3 participants