Closed vmx17 closed 1 year ago
Hi,
You can find a full DirectN + WinAppSDK WinUI3 sample here https://github.com/smourier/DirectN/tree/master/DirectN/DirectN.WinUI3.MinimalD3D11
In the main file MainWindow.xaml.cs you will see I have redeclared ISwapChainPanelNative
manually as it's not the same as the one from UWP's SwapChainPanel
, they only differ by the GUID (it makes sense, sort of, thanks Microsoft for that nice trick :-)): https://github.com/smourier/DirectN/blob/master/DirectN/DirectN.WinUI3.MinimalD3D11/MainWindow.xaml.cs#L309
Here is how you should declare it:
[ComImport, Guid("63aad0b8-7c24-40ff-85a8-640d944cc325"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public partial interface ISwapChainPanelNative
{
[PreserveSig]
HRESULT SetSwapChain(IDXGISwapChain swapChain);
}
Thank you so much. I could get compiled. So, is the Guid depends on "microsoft.ui.xaml.media.dxinterop.h" header with which DirectN compiled? When and how should I looking for the changed Guid? It seems not parmanent.
I appreciate your many help.
DirectN's ISwapChainPanelNative
depends on the Windows SDK headers (windows.ui.xaml.media.dxinterop.h
), so it will have IID set to F92F19D2-3ADE-45A6-A20C-F6F1EA90554B
. This is for UWP projects.
ISwapChainPanelNative
with IID set to 63aad0b8-7c24-40ff-85a8-640d944cc325
depends on Windows App SDK headers (microsoft.ui.xaml.media.dxinterop.h
). DirectN currently doesn't include Windows App SDK headers support. This is something I'm considering to add in the future (but in another namespace because of name collisions).
I see. I'll try to take care when same issue occur. Thank you.
Hi! I'm using DirectNCore, downloaded as an NuGet package in WindowsAppSDK desktop project. Now I hit to an exception saying
Exception thrown: 'System.InvalidCastException' in WinRT.Runtime.dll
before callingSetSwapChain()
. If you have any suggestions, please let me know. The code below;The
_pnl
isSwapChainPanel
I specified in XAML asMicrosoft.UI.Xaml.Controls.SwapChainPanel
. Though there was similar subject, I could not figure out howmicrosoft.ui.xaml.media.dxinterop.h
concerns. The \<\<peek definition>> shows decompiled result;The Guid seems differ from the article. My environment VS2022Pro 17.6.1, .Net 6.0, WindowsAppSDK, all packages are latest fixed.