I have a project, that I previously developed with .NET Framework 4.8.1. And I had no issues adding .ico resources and accessing them via Properties.Resources whatsoever.
Recently I tried to migrate my project to .NET 8.0. And here comes the issue:
Whenever I try to add a resource of type System.Drawing.Icon, I get an error “Type System.Drawing.Icon cannot be located.”. But the .ico file is getting added to Resources/ folder.
I can access System.Drawing.Icon class itself from any .cs file, my references in .csproj look like this
<ItemGroup>
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.8" />
<PackageReference Include="System.Drawing.Common" Version="8.0.8" />
</ItemGroup>
Which suggests that I have access to System.Drawing.
Maybe someone had a simmilar issue? Is there a workaround for this? I need to use Icon type, because I want to use one .ico file for many things, such as displaying it in “System.Windows.Forms.NotifyIcon” tray, which accepts only System.Dtawing.Icon to display. I would be forewer grateful for a solution.
I tried converting System.Byte[] (WPF) to System.Drawing.Icon, but had no luck.
I also tried to hard-code .ico directly into .cs file, but had no luck either.
beispielsweise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
0