dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.04k stars 1.17k forks source link

Unable to load COM components in.NET 5.0 WPF #4534

Closed lifuhua123 closed 3 years ago

lifuhua123 commented 3 years ago
lifuhua123 commented 3 years ago

无标题 无标题

lindexi commented 3 years ago

@lifuhua123 Adding the WinForms reference to your project by edit your csproj file.

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFrameworks>netcoreapp3.1;net5-windows</TargetFrameworks>
    <UseWPF>true</UseWPF>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

</Project>
双击项目文件,进入编辑项目文件,项目文件就是 csproj 文件,尝试在 PropertyGroup 里面加上 UseWindowsForms 属性,如上面代码