WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

XAML hosting is not working in Active Document Containment scenario

Open Ajith-GS opened this issue 6 months ago • 2 comments

Describe the bug

We have been using an Active Document server application that is embedded in an Active Document container application by creating an OLE object for the server application. A sample application with the same implementation is attached. We have several such kinds of server applications embedded in the same container application. As a part of the modernization, WinUI3 XAML hosting is performed, and its success full if we invoke the server application alone(standalone invoking). However if we invoke the container application, during the in-place activation of the server object using the DoVerb method, following error is occurred and the initialized DesktopWindowXamlSource is closing unexpectedly.

Msg:[HWND 0000000001031156 changed parent from 00000000011F0F7C to 0000000000F71198. Unsupported scenario.] MyActiveServer.exe: WinRT originate error - 0x8007139F : 'WindowParentChain invalid state.'.

From my understanding, the Windows App SDK 1.4 or later does not support the HWND parent chain changing while DesktopWindowXamlSource is in use, as mentioned in the GitHub issue #8900 .

But Active Document Containment is a generally using technology to embed an active document server object within another active document container as mentioned in the MSDN( https://learn.microsoft.com/en-us/cpp/mfc/active-document-containment?view=msvc-170). Why Windows App SDK is unable to support this kind of scenario?

Is there a workaround available currently to address the issue mentioned above? I would be very grateful for any assistance.

Steps to reproduce the bug

CompoundDocTest.zip contains the following projects to simulate the above scenario.

  • MyActiveContainer - Active document container project.
  • MyActiveServer - Active document server project.
  • WinUI3xTest_DLL - WinUI 3 DLL from which XAML control is hosted on MyActiveServerView .
  1. Build WinUI3xTest_DLL, MyActiveServer and MyActiveContainer in Release-x64 configuration.
  2. Launch CMD with Administrator privilege and change directory to MyActiveServer.exe location.
  3. Register the MyActiveServer using the command MyActiveServer.exe /RegServer
  4. Execute MyActiveContainer.exe.
  5. Click on "Invoke MyActiveServer Application" button.

Expected behavior

XAML control from WinUI3xTest_DLL should be hosted on CMyActiveServerView successfully.

Screenshots

Standalone execution of MyActiveServer.exe. ServerApp

Execution of MyActiveContainer.exe. ContainerApp

NuGet package version

Windows App SDK 1.5.5: 1.5.240627000

Packaging type

Unpackaged

Windows version

Windows 10 version 22H2 (19045, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

Ajith-GS avatar Aug 01 '24 11:08 Ajith-GS