Making an agile version of a Windows Runtime delegate in C++/WinRT, part 3
cppdashboard.dev/r/2026/08/making-an-agile-version-of-a-windows-runtime-delegate-in-cpp-8This article discusses optimizations for creating agile versions of Windows Runtime delegates in C++/WinRT, particularly focusing on handling objects that implement the INoMarshal interface. It explains how to manage exceptions when invoking wrappers across different contexts.
From the article
Last time, we made a small but significant optimization to making an agile version of a Windows Runtime delegate . But there’s another case we missed.
That case is an object that implements the INoMarshal interface, which means “Do not marshal this object.” For these objects, the RoGetAgileReference function fails to create an agile reference and returns CO_ E_ NOT_ SUPPORTED . This function is what powers the agile_ ref class, so if you ask for an agile_ ref to an object that refuses to be marshaled, you get an CO_ E_ NOT_ SUPPORTED exception.
The catch is that this error is produced at the creation of the agile reference. If in practice all your uses of the agile reference are from the original context, you never actually needed to marshal the object, but too bad, you get the…
Share this resource