Add marshaling support for COM implementations #3531
Merged
+970
−97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In many cases, an explicit
IMarshalinterface implementation is not required when implementations supportIAgileObject. But there are cases when this is insufficient and COM demands an implementation ofIMarshal.This update adds a universal implementation of
IMarshalfor all COM objects produced bywindows-rsincluding theimplementmacro, delegates, and weak references. This implementation is based on the system's free-threaded marshaler and is implemented identically to the way I originally implemented it for C++/WinRT which has stood the test of time. Specifically,IMarshalis implemented as a tear-off to avoid any overhead in the common case where marshaling is not required.Here's a simple client-server example to illustrate what this enables. Here's the server that uses
CoRegisterClassObjectto register and host a class factory:And here's a client that uses
CoCreateInstanceto remotely connect to the server:Fixes: #753