-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
In .NET 9 Preview 2, WinForms moved to avoid WinForms threads always registering with existing IMsoComponentManager instances. This now is an opt in behavior if developers need existing IMsoComponentManager instances to be registered to their WinForms threads.
Version
Other (please put exact version in description textbox)
Previous behavior
Windows Forms threads always registered with existing IMsoComponentManager instances.
New behavior
WinForms threads will not automatically get integration with process registered IMsoComponentManagers. If users want this old behavior users will need to set the switch "Switch.System.Windows.Forms.EnableMsoComponentManager".
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
For performance and efficiency. Previous behavior presented a lot of overhead as COM is being used and not all developers need this behavior.
Recommended action
Opt in for IMsoComponent support via the switch either by:
Adding the following to runtimeconfig.json
{
"configProperties": {
"Switch.System.Windows.Forms.EnableMsoComponentManager": true
}
}
or
Adding a RuntimeHostConfigurationOption in the project file:
<ItemGroup>
<RuntimeHostConfigurationOption Include="Switch.System.Windows.Forms.EnableMsoComponentManager" Value="true" />
</ItemGroup>
Feature area
Windows Forms
Affected APIs
https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/ff518955(v=office.12)
https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/ff518963(v=office.12)