ComActivator causes linker to include code which is not needed in most cases #43604
Labels
area-Interop-coreclr
size-reduction
Issues impacting final app size primary for size sensitive workloads
Milestone
CoreCLR
ComClassFactory::CreateInstanceFromClassFactory
calls into managedInternal.Runtime.InteropServices.LicenseInteropProxy.Create
(and some other methods as well). This dependency is hardcoded in theSystem.Private.CoreLib
descriptor and so linker can't ever remove theLicenseInteropProxy
.This type brings in a lot of dependencies (ultimately even
BinaryFormatter
) which also have some trim analysis warnings.This functionality should not be needed when COM support is turned off - see COM Feature switch.
Also - this functionality is probably only needed when managed COM activation is used by the project - that is, it can only ever be called if
ComActivator
was used.Vast majority of .NET Core projects don't use
ComActivator
and thus including this code is unnecessary.What to do about this:
ComClassFactory::CreateInstanceFromClassFactory
which calls intoLicenseInteropProxy
can only be used whenComActivator
is also used. If this is not true, then more work is needed to determine what to do.LicenseInteropProxy
always, make it a dynamic dependency (viaDynamicDependencyAttribute
) of theComActivator
(the right method on it) and remove it from the CoreLib's ILLink descriptor.LicenseInteropProxy
is not present in a normal console hello world (even without any feature switches)ComActivator
should be hidden behind the feature switch, but maybe some small pieces will be left-over).The text was updated successfully, but these errors were encountered: