Skip to content

Fix ActivateInstance parameter#2476

Open
manodasanW wants to merge 3 commits into
staging/3.0from
manodasanw/defaultInterface
Open

Fix ActivateInstance parameter#2476
manodasanW wants to merge 3 commits into
staging/3.0from
manodasanw/defaultInterface

Conversation

@manodasanW

Copy link
Copy Markdown
Member

Fix ActivateInstance parameter to reflect that it is not guaranteed to be the default interface but rather could just be IInspectable

…o the default interface but rather could be IInspectable
@riverar

riverar commented Jun 28, 2026

Copy link
Copy Markdown

Can we get more background (if any) on this and potentially edit the docs https://learn.microsoft.com/windows/win32/api/activation/nf-activation-iactivationfactory-activateinstance

@riverar

riverar commented Jun 28, 2026

Copy link
Copy Markdown

@oldnewthing https://devblogs.microsoft.com/oldnewthing/20201028-00/?p=104404 and https://devblogs.microsoft.com/oldnewthing/20200324-00/?p=103586 make claims about object representation "at the ABI" that could use some clarification. (These articles came up in a discussion about this issue.) My suspicion is that you were describing ABI behavior from a C++/WinRT-authored-component perspective, rather than stating overarching rules for all WinRT objects right?

Comment thread src/WinRT.Runtime2/WindowsRuntimeObject.cs Outdated
Introduce an overload of WindowsRuntimeActivationHelper.ActivateInstanceUnsafe that accepts an IID and returns the default interface pointer. The new method activates the factory to get an IInspectable, queries for the requested interface via QueryInterface, and releases the temporary IInspectable. It preserves HRESULT handling via RestrictedErrorInfo and uses NoInlining attribute. This enables callers using the parameterless constructor path to obtain the actual default interface from activation factories.
Simplify sealed-type activation by having WindowsRuntimeActivationHelper.ActivateInstanceUnsafe return the default interface directly. Removes manual QueryInterface/Release logic and related temporary pointer handling, reducing complexity and potential lifetime errors during activation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CsWinRT 3.0 crashes, assumes ActivateInstance instance implements default interface

3 participants