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.
You need to #include <unknwn.h>
before any cppwinrt header to enable classic COM support.
Useful reading (both articles written by Raymond Chen):
Why does C++/WinRT say that first_interface
is not a member of winrt::impl::interface_list<>
?
I noted that by default C++/WinRT requires interfaces to derive from
winrt::Windows::Foundation::IUnknown
. You can activate nondefault behavior by including theunknwn.h
header file before including any C++/WinRT header files, in which case C++/WinRT will also recognize types which derives from classic COMIUnknown
as interfaces.
The various ways of moving between C++/WinRT and classic COM