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

Shyam Butani 380 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 development | Windows API - Win32
Developer technologies | Visual Studio | Debugging
Windows for business | Windows Server | User experience | Print jobs
{count} vote

Accepted answer
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    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.