How can I figure out the class name from an interface ID (IID) in WinRT?
Asked Answered
C

3

5

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?

Chauffeur answered 10/4, 2019 at 2:4 Comment(0)
S
6

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.

Scapegoat answered 5/7, 2019 at 18:54 Comment(0)
P
4

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

Profusion answered 26/4, 2019 at 5:27 Comment(0)
C
1

I had the same problem as you.

All Xaml / Windows RT interfaces implement the IInspectable interface which has a method GetIids() which retuns all interfaces to which the current interface can be casted (QueryInterface in COM terms). I wanted to know what these IID's mean.

Therefore I wrote a tool which parses all header files in the Windows SDK and extracts all interfaces with their full name and IID.

I ran this over the Windows 11 SDK and it finds 9300 Windows RT interfaces. I can even run it over all Windows COM interfaces and it finds 25600 interfaces.

Here you see a small extract from the auto generated INI file which also contains your interface.

.....
30DA92C0-23E8-42A0-AE7C-734A0E5D2782 = ABI.Windows.UI.Xaml.Data.ICustomProperty
7C925755-3E48-42B4-8677-76372267033F = ABI.Windows.UI.Xaml.Data.ICustomPropertyProvider
83B834BE-0583-4A26-9B64-8BF4A2F65704 = ABI.Windows.UI.Xaml.Data.IItemIndexRange
86E2C440-2E7A-4C7D-A664-E8ABF07BFC7E = ABI.Windows.UI.Xaml.Data.IItemIndexRangeFactory
F05F5665-71FD-45A2-BE13-A081D294A68D = ABI.Windows.UI.Xaml.Data.IItemsRangeInfo
CF75D69C-F2F4-486B-B302-BB4C09BAEBFA = ABI.Windows.UI.Xaml.Data.INotifyPropertyChanged
4F33A9A0-5CF4-47A4-B16F-D7FAAF17457E = ABI.Windows.UI.Xaml.Data.IPropertyChangedEventArgs
6DCC9C03-E0C7-4EEE-8EA9-37E3406EEB1C = ABI.Windows.UI.Xaml.Data.IPropertyChangedEventArgsFactory
 50F19C16-0A22-4D8E-A089-1EA9951657D2 = ABI.Windows.UI.Xaml.Data.IPropertyChangedEventHandler
2397CE84-2822-483A-B499-D0F031E06C6B = ABI.Windows.UI.Xaml.Data.IRelativeSource
EF8392CD-446E-4F93-AACB-9B1255577460 = ABI.Windows.UI.Xaml.Data.IRelativeSourceFactory
2E12CA86-E1ED-4245-BE49-207E42AEC524 = ABI.Windows.UI.Xaml.Data.ISelectionInfo
7F5EE992-7694-4E6C-A51B-E34BF43DE743 = ABI.Windows.UI.Xaml.Data.ISupportIncrementalLoading
E6F2FEF0-0712-487F-B313-F300B8D79AA1 = ABI.Windows.UI.Xaml.Data.IValueConverter
4BCE0016-DD47-4350-8CB0-E171600AC896 = ABI.Windows.UI.Xaml.Documents.IBlock
.....

My tool outputs the result as HTML, XML, INI, C# and C++. The CSharp and Cpluplus files contain a function which converts a GUID into the interface name.

You don't need to install the Windows SDK. I already did this and uploaded the auto-generated files.

The project (with source code) WindowsRT-GUID-Analyzer

And the Ini file with all 15000 Windows COM interfaces: All Windows 11 Interfaces

The other files are also in the Release folder in Github.

Cene answered 17/3, 2022 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.