Search code examples
c++visual-c++webview2

fixing 'no matching overloaded function found'


What compiler setting(s) do I need to set in order to avoid:

Error C2672 'unbox_value_type': no matching overloaded function found C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\cppwinrt\winrt\Windows.Foundation.h 2901

The Windows.Foundation.h file is read only, and I'd like to keep it that way.

I'm trying to create a Windows application that uses WebView2. I installed VS2022 (free version), downloaded the WebView2 sample (the sample solution builds OK). I created a new project, and I'm trying to add fragments to it from the sample, but the compiler errors out on the file mentioned above, on line 2901.


Solution

  • You need to #include <unknwn.h> before any cppwinrt header to enable classic COM support.

    Useful reading (both articles written by Raymond Chen):