-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: AOT doesn't work with interfaces #1890
Comments
Did you copy the produced winmd files to the directory of your executable file? |
@hez2010 I just tried but it still doesn't work. |
This looks to be a generator miss. Can you confirm if adding this works for you? [global::WinRT.WinRTExposedType(typeof(global::WinRT.AuthoringDemoVtableClasses.ABI_Impl_AuthoringDemo_ChildWinRTTypeDetails))]
partial class Child
{
}
namespace WinRT.AuthoringDemoVtableClasses
{
internal sealed class ABI_Impl_AuthoringDemo_ChildWinRTTypeDetails: global::WinRT.IWinRTExposedTypeDetails
{
public global::System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry[] GetExposedInterfaces()
{
return new global::System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry[]
{
new global::System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry
{
IID = global::ABI.AuthoringDemo.IParentMethods.IID,
Vtable = global::ABI.AuthoringDemo.IParentMethods.AbiToProjectionVftablePtr
},
new global::System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry
{
IID = global::ABI.AuthoringDemo.IChildMethods.IID,
Vtable = global::ABI.AuthoringDemo.IChildMethods.AbiToProjectionVftablePtr
},
};
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
My code is like below
But it doesn't compile because "error CsWinRT1005: Exporting unsealed types is not supported in CsWinRT, please mark type Parent as sealed"
I use interfaces as workaround, and change my code to
And it works well.
Next, I enable AOT following https://github.com/MichalStrehovsky/CppPublishAotReference
When I run the code, I see below error:
Exception thrown at 0x00007FFC28D2837A (KernelBase.dll) in CppConsoleApp.exe: WinRT originate error - 0x80004002 : 'Failed to create a CCW for object of type 'AuthoringDemo.Parent' for interface with IID 'F4D7DFF0-F052-5B09-8FB3-7B563C3D0E1C': the specified cast is not valid.'.
Exception thrown at 0x00007FFC28D2837A (KernelBase.dll) in CppConsoleApp.exe: WinRT originate error - 0x80004002 : 'Failed to create a CCW for object of type 'AuthoringDemo.Child' for interface with IID '58D127C1-2630-5E63-8877-42BC48D395E8': the specified cast is not valid.'.
Steps To Reproduce
Expected Behavior
The code can run successfully.
Version Info
CsWinRT version: 2.2.0
DotNet version: net8.0-windows10.0.22621.0, net9.0-windows10.0.22621.0
Additional Context
No response
The text was updated successfully, but these errors were encountered: