C#C
C#2y ago
7 replies
Vlad

Initialize COM object in .Net 8 when using the new GeneratedComInterface and NativeAOT

Hey everyone, I'm trying to NativeAOT my app that uses COM for interaction with WasAPI. I've converted all my code to use the new .Net 8 GeneratedComInterface code generation feature, but I've reached a wall.

I need to initialize a COM object of a particular type ("BCDE0395-E52F-467C-8E3D-C4579291692E") which inherits the interface ("A95664D2-9614-4F35-A746-DE8DB63617E6").

Previous I did this by just specifying the class, doing new() and casting it to the interface - which worked despite the class not inheritting the interface on the C# side. Now with GeneratedComInterface and GeneratedComClass it requires me to pair them together, but I don't have the implementation - I just want to consume the object.

What is the right way to declare the class initialize the object?
Was this page helpful?