-
Couldn't load subscription status.
- Fork 215
Closed
Labels
area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation.NET runtime optimized for ahead of time compilationhelp wantedExtra attention is neededExtra attention is needed
Description
The Native AOT compiler does not support COM interop today. Attempt to use COM interop leads to errors like:
Unhandled Exception: System.PlatformNotSupportedException: COM Interop is not supported on this platform.
at Internal.Runtime.CompilerHelpers.InteropHelpers.ConvertManagedComInterfaceToNative(Object) + 0x42
The right way to add support for COM interop to Native AOT runtime is combination of:
- Implement ComWrappers in the Native AOT runtime.
-
Add CoreCLR ComWrappers implementation to Native AOT build. - Implement CCW -
CreateComInterfaceForObjectset of APIs - Implement RCW -
CreateObjectForComInstanceset of APIs -
ComWrappers.RegisterForMarshalling- needed to replace built-in interop -
ComWrappers.RegisterForTrackerSupport- WinRT-specific lifetime management
-
- Implement IDynamicInterfaceCastable in the Native AOT runtime. CoreRT had a similar experimental feature before that was reverted in dotnet/corert@5383d46 . This commit provides approximate blue print for what the implementation should look like.
- Implemented support for shared generics with
IDynamicInterfaceCastableSupport IDynamicInterfaceCastable with shared generic code runtime#72909 - External tool that generates the required COM marshaling stubs. There are several design options for how this tool can work; or there can even be multiple variants of this tool. The key difference between the different options is the source of truth that the tool consumes.
- Source of truth are COM interface definitions in C#. This option is best for making the existing libraries that use COM interop work (e.g. WinForms or Avalonia). Source generator that is extension of DllImportGenerator may be a good implementation strategy for this option.
- Source of truth are COM interface definitions in IDL or TLB file. This option is best for creating new libraries that use COM interop. The tool for this case would be conceptually similar to cswinrt tool for WinRT.
dotnet/corert#4219 has more discussion on this topic.
charlesroddie, Shadowblitz16, hez2010, CXCubeHD, rgwood and 9 more
Metadata
Metadata
Assignees
Labels
area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation.NET runtime optimized for ahead of time compilationhelp wantedExtra attention is neededExtra attention is needed