共用方式為


IMsoComponent 支援為選擇加入

進行了變更以避免 Windows Forms 執行緒一律向現有 IMsoComponentManager 執行個體註冊。 但是,您可以選擇將現有 IMsoComponentManager 執行個體註冊到 Windows Forms 執行緒。

導入的版本

.NET 9 Preview 2

先前的行為

先前, Windows Forms 執行緒一律向現有 IMsoComponentManager 執行個體註冊。

新的行為

從 .NET 9 開始,Windows Forms 執行緒不再自動與處理序註冊的 IMsoComponentManagers 整合。 若要恢復先前的行為,請設定參數 Switch.System.Windows.Forms.EnableMsoComponentManager

變更類別

此變更為行為變更

變更原因

此變更是為了提升效能和效率。 先前的行為由於使用 COM 而帶來許多額外負荷,並且並非所有開發人員都需要此行為。

如果您希望恢復先前的行為,可以使用 runtimeconfig.json 檔案中的參數,或作為專案檔案中的 RuntimeHostConfigurationOption 項目來選擇加入 IMsoComponent 支援。

runtimeconfig.json 檔案:

{
  "configProperties": {
    "Switch.System.Windows.Forms.EnableMsoComponentManager": true
 }
}

專案檔:

<ItemGroup>
  <RuntimeHostConfigurationOption Include="Switch.System.Windows.Forms.EnableMsoComponentManager" Value="true" />
</ItemGroup>

受影響的 API