I have a XAML C++/WinRT application based on the BlankApp template. As I built up the app, I realized that my application is throwing a lot of exceptions behind the scenes in my output window. The exception I'm trying to understand is the following:
Exception thrown at 0x00007FFA9EFA9149 (KernelBase.dll) in wzrd_editor.exe: WinRT originate error - 0x80040155 : 'Failed to find proxy registration for IID: {50F19C16-0A22-4D8E-A089-1EA9951657D2}.'.
What I have been doing is breaking on WinRT originate errors and looking at the call stack. However I am wondering how can I figure out the class name of the IID that is shown in the error? It seems like that would be very useful to know to figure out the source of these exceptions. Maybe there's somewhere in the registry where I can find out?
The underlying issue here is that Xaml delegates are a little simple (the delegates that Xaml implements to subscribe to events raised by an app). Even though they are effectively agile, they neither implement IAgileObject nor IMarshal. There is no way for a language projection to know anything about the delegate without probing and this results in the noise in the debugger, although this is not caused by an exception but rather by a call to RoOriginateXxx.
C++/WinRT only stores agile delegates to ensure apartment correctness. It then has to work around this limitation in the Xaml implementation by first checking whether a delegate is agile (by querying for IAgileObject). If this fails, it attempts to create an agile reference (to accommodate marshalable delegates like those created by JavaScript). If this fails, it smuggles the delegate because there’s no other choice. It’s this last category that accommodates Xaml, but it means that the debugger will report the “Failed to find proxy registration for IID” error for any Xaml-provided delegate.
The question conflates two concepts, runtime classes and interfaces. Runtime classes are named types that are implemented via a set of interfaces, some of which may be unique to the class, while others may be implemented on many classes.
For system types, the C++ headers in the SDK will contain definitions for all interfaces, public & private, and you can search them for the GUID to map back to the class. Although sometimes interfaces may appear in the registry with names as well, this is not guaranteed.
I did a quick search, and I can see that the interface mentioned in the error is Windows.UI.Xaml.IPropertyChangedEventHandler
, which is the underlying interface for the delegate PropertyChangedEventHandler
. Since this is part of XAML, the expectation is that these interfaces should be implemented by agile objects and should always be invoked on the UI thread.
The error indicates that your non-agile delegate was either registered in one apartment and invoked in another. You can address this by either making your delegate agile or by creating and registering it on the UI thread.
Thanks,
Ben
User contributions licensed under CC BY-SA 3.0