Exception: "Element Not Found" while calling StartDoc() in Visual Studio 2022 debugger

Shyam Butani 235 Reputation points
2024-03-28T09:23:17.2666667+00:00

I am attempting to print from a Desktop application using the following APIs:

  • StartDoc (...)
  • StartPage (...)
  • TextOut (...)

When I run my application using Visual Studio 2022 Debugger, StartDoc() throws an exception as shown in the image below. However, when I run the .exe file directly, it works without any issues. Could you please explain the reason behind this behavior of the VS2022 Debugger?"

User's image

// Output window

Print.PrintSupport.Source.dll!00007FF8189A0417: ReturnHr(1) tid(3cd8) 80070490 Element not found.
    Msg:[onecoreuap\printscan\print\workflow\printsupport\dll\printsupportutil.cpp(574)\Print.PrintSupport.Source.dll!00007FF818975BA8: (caller: 00007FF818986287) Exception(1) tid(3cd8) 80070490 Element not found.
] 
Print.PrintSupport.Source.dll!00007FF818977238: LogHr(1) tid(3cd8) 80070490 Element not found.
Exception thrown at 0x00007FF84DA95B0C (KernelBase.dll) in TWTallySCPNative.exe: WinRT originate error - 0x80070490 : 'Element not found.'.
Exception thrown at 0x00007FF84DA95B0C in TWTallySCPNative.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x000000DED81FC470.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,651 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,004 questions
Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
688 questions
{count} vote

Accepted answer
  1. Jeanine Zhang-MSFT 9,771 Reputation points Microsoft Vendor
    2024-03-29T01:15:49.0233333+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I suggest you could ignore that exception: Debug -> Windows -> Exception Settings, C++ Exception, and then uncheck winrt::hresult_error.

    User's image

    User's image

    Thank you.

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.