-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to turn off COM support in Windows #50500
Comments
/cc @eerhardt |
@AaronRobinsonMSFT, this is meant to contribute towards #36659. It seems better to have a separate issue to track turning COM off independent of Trimming. Once we have that, #36659 should be the trimmer side work (descriptor file changes, publish related properties etc.) with this switch OFF |
ApartmentState is pay-for-play, costs very little and it affects non-COM APIs like WaitHandle. I think we should leave it as is, independent on this switch. |
Is independent of the COM Activation scenario. CCWs are created whenever a managed object is marshalled as an "interface" across the managed/native boundary - which means one can pass a managed object through a P/Invoke.
Appreciate the callout of the two wrapper concepts and we can think about them distinctly here. From a technical standpoint however, they are so intertwined that there is no way to address them independently - even at the scenario level. For example, COM Aggregation which merges a wrapper of each type. |
Note that majority of the COM support is in the unmanaged VM code today. This will need to disable the COM support on number of places in the VM too to be consistent and complete. Also, this should not affect ComWrappers. Pay-for-play interop implemented via ComWrappers should continue to work even when the built-in COM support is disabled. ComWrappers should be our recomended solution for libraries or apps that use COM and would like to work even with the built-in COM support disabled.
Nit: "explict" does not sound right to me in this context. It may be better to describe it as "built-in support". |
Should turning off |
I take a look at runtime repository and usage of ComImport attribute,
Each of this assemblies has about 6-10 classes decorated. |
I don't think there is a present plan for that. It is going to require some auditing of the systems to ensure they don't depend on features of COM that would be difficult in a |
Closing this given the planned work was completed |
Applications that do not use COM in windows should have the option to not have any COM related code in their application. We should consider adding a feature switch that will turn off COM for applications in such cases. This feature switch can be ON by default for Windows.
Turning COM support OFF means that the application does not expect any built-in support from .NET to call into COM components (RCW) or allow any other COM Client to call in to the application as a COM Server (CCW).
Setting this feature switch OFF will allow applications to be trimmed in a safe way. Issue #36659 tracks this for trimming.
Given COM support is pervasive in .NET code and also the implicit nature of .NET support for COM, it is challenging to find all the places that will be needed to be touched to turn COM OFF. We can start with the following:
Add a property to
System.Runtime.InteropServices.Marshal
to turn off COM. i.eMarshal.IsBuiltInComSupported
(internal property) that can be set via a runtime config option,System.Runtime.InteropServices.BuiltInComInterop.IsSupported
Support for COM Callable Wrapper (CCW)
FEATURE_COMINTEROP_UNMANAGED_ACTIVATION
Support for Runtime Callable Wrapper (RCW)
FEATURE_COMINTEROP
. For example, in Type.InvokeMemberType Support
Below are the exceptions:
ComWrappers is the recommended solution for libraries or apps that use COM and should work even with the built-in COM support disabled
Keep ApartmentState support
FEATURE_COMINTEROP_UNMANAGED_ACTIVATION
. For example in Thread class should not be removedThe first iteration to turn OFF COM support will not focus on removing VM code
The text was updated successfully, but these errors were encountered: