© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
31 replies
jborean

✅ COM + NativeAOT Help

I'm fairly new to COM and I'm trying to implement an RDP Dynamic Virtual Channel client dll which uses the
IWTSPlugin
IWTSPlugin
COM interface https://learn.microsoft.com/en-us/windows/win32/api/tsvirtualchannels/nn-tsvirtualchannels-iwtsplugin. Can anyone point out what I might be doing wrong here https://gist.github.com/jborean93/394592c89fc8bfd54990d814a29b924f as this just crashes my process and the
WTSPlugin-log.txt
WTSPlugin-log.txt
is never created.

I'm not 100% confident on how I'm setting the COM pointer on the
VirtualChannelGetInstance
VirtualChannelGetInstance
implementation but I know for sure that
mstsc
mstsc
is calling that particular method it as the logs are showing that it is called and the process crashes because I am doing something dumb.

I do have a few other questions that hopefully someone might be able to clarify

+ Do I need to save the
WTSPlugin
WTSPlugin
and
StrategyBasedComWrappers
StrategyBasedComWrappers
instance or can they be discarded once I've passed the pointer to the unmanaged instance
+ What is the correct way to define another COM interface (pointer to the interface type in COM land) as an argument
+ Are there any recommendations for
PreserveSig
PreserveSig
or not having it
Gist
IWTSPlugin.cs
GitHub Gist: instantly share code, notes, and snippets.
IWTSPlugin.cs
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

NativeAOT + emscripten
C#CC# / help
5mo ago
NativeAOT multiple Dlls
C#CC# / help
5w ago
NativeAOT Serialization Troubles
C#CC# / help
11mo ago
Initialize COM object in .Net 8 when using the new GeneratedComInterface and NativeAOT
C#CC# / help
2y ago