Simon Mourier's comments is the answer is used. I have decompiled the generated tlb dll back into C# using ILSpy . Then pseudo-manually and with help of AI to speed it up I converted attributes on the interfaces to using GeneratedComInterface
instead of ComImport
. Fortunately, the COM interface I am using is relatively basic, so this wasn't that difficult with no custom marshalling required.
Simon's comment provides a link with documentation for the basic cases I needed: https://learn.microsoft.com/en-us/dotnet/standard/native-interop/comwrappers-source-generation