You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Built-in COM interop is not available when trimming or AOT are enabled. We need to use ComWrappers in those scenarios. This is important where we currently publicly expose COM RCWs. One concrete example of this is in AxHost. AxHost.GetOcx exposes the ActiveX instance and it is also exposed via the customizable construction virtual AxHost.CreateInstanceCore(Guid clsid).
We need to add a helper in ComHelpers that handles falling back to ComWrappers when necessary. The simple implementation would be something like this:
We should also consider a switch that allows forcing the ComInterfaceMarshaller and potentially picking it by default if the reflection based support for casting to [ComImport] interfaces is enabled. ("System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop" AppContext flag or "EnableGeneratedComInterfaceComImportInterop" in MSBuild)
The only issue with the ComInterfaceMarshaller is that presumes objects are free-threaded. We can deal with this by implementing our own IUnknownStrategy that wraps the GIT much as our AgileComPointer does. This would require deriving from StrategyBasedComWrappers and returning a new instance of the strategy by overriding GetOrCreateIUnknownStrategy().
The text was updated successfully, but these errors were encountered:
not sure how much this is related, but there is desire of having AxHost work in trimming/NativeAOT scenarios. I'm currently doing handwritten bindings in #10583 to get the basics working for source generators - but while the ActiveX control itself currently can be (manually) written using COM source generators, WinForms itself (AxHost interaction) needs work done to drop classic COM interop
Built-in COM interop is not available when trimming or AOT are enabled. We need to use
ComWrappers
in those scenarios. This is important where we currently publicly expose COM RCWs. One concrete example of this is inAxHost
.AxHost.GetOcx
exposes the ActiveX instance and it is also exposed via the customizable construction virtualAxHost.CreateInstanceCore(Guid clsid)
.We need to add a helper in
ComHelpers
that handles falling back toComWrappers
when necessary. The simple implementation would be something like this:We should also consider a switch that allows forcing the
ComInterfaceMarshaller
and potentially picking it by default if the reflection based support for casting to[ComImport]
interfaces is enabled. ("System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop" AppContext flag or "EnableGeneratedComInterfaceComImportInterop" in MSBuild)The only issue with the
ComInterfaceMarshaller
is that presumes objects are free-threaded. We can deal with this by implementing our ownIUnknownStrategy
that wraps the GIT much as ourAgileComPointer
does. This would require deriving fromStrategyBasedComWrappers
and returning a new instance of the strategy by overridingGetOrCreateIUnknownStrategy()
.The text was updated successfully, but these errors were encountered: