I am building simple media player, written in c#. It's Windows Forms app and by .csproj file my target framework is net5.0-windows.
I want to use wmp.dll.
The problem is, Visual Studio 2019 shows me an error message "The reference is invalid or unsupported". I got this when via solution explorrer added a reference to wmp.dll.
wmp.dll is located in my PC in C:\Windows\System32 directory.
I also tried to download wmp.dll using nuget package. When I done this I have got the following code in .csproj file
<ItemGroup>
<PackageReference Include="Up3.5" Version="1.0.0" />
<PackageReference Include="WMPLib" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
And still I can not use WMPLib in my project. I appreciate any help.
Edit
I added a direct reference to wmp.dll in nuget package. But I dont know if I can rely on this when I will make my project an executable.
Visual Studio error message when adding the reference
That's my .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<Compile Update="Presentation\Form1.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Up3.5" Version="1.0.0" />
<PackageReference Include="WMPLib" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\.nuget\packages\wmplib\1.0.0\lib\Interop.WMPLib.dll</HintPath>
</Reference>
<Reference Include="PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationCore.dll</HintPath>
</Reference>
</ItemGroup>
</Project>