You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting "'Icon' is obsolete" warning on build #247
The icon class in WinUI has issues with high-resolution icons, and have since been replaced by Microsoft's own icon methods. You can use the Window's icon methods: ie MyWindow.AppWindow.SetTitleBarIcon(...), MyWindow.AppWindow.SetIcon(...) and MyWindow.AppWindow.SetTitleBarIcon(...)
WinUIEx will generally deprecate features as the WinAppSDK offers new SDKs with the same features.
I'll look into updating the obsolete warning to make this more clear.
You wrote Window.SetIcon, not AppWindow.SetIcon. The one on AppWindow is part of the WinAppSDK and not part of WinUIEx and shouldn't give you an obsolete warning.
I'm getting the same warnings coming from TaskBarIcon in XamlTypeInfo.g.cs when I use WindowEx, even though I am not setting it (I can do global replace for WindowEx to Window and the only change is these warnings).
I am not getting any warnings for SystemBackdrop despite it also being marked obsolete, and the only difference seems to be whether the Obsolete attribute has a description, and whether there is an EditorBrowsable(EditorBrowsableState.Never) attribute.
1>D:\Source\Experiments\obj\x86\Debug\net9.0-windows10.0.26100.0\XamlTypeInfo.g.cs(308,36,308,56): warning CS0612: 'Icon' is obsolete
1>D:\Source\Experiments\obj\x86\Debug\net9.0-windows10.0.26100.0\XamlTypeInfo.g.cs(422,134,422,154): warning CS0612: 'Icon' is obsolete
1>D:\Source\Experiments\obj\x86\Debug\net9.0-windows10.0.26100.0\XamlTypeInfo.g.cs(576,51,576,71): warning CS0612: 'Icon' is obsolete
1>D:\Source\Experiments\obj\x86\Debug\net9.0-windows10.0.26100.0\XamlTypeInfo.g.cs(1153,33,1153,53): warning CS0612: 'Icon' is obsolete
You wrote Window.SetIcon, not AppWindow.SetIcon. The one on AppWindow is part of the WinAppSDK and not part of WinUIEx and shouldn't give you an obsolete warning.
Yes sorry, I mistyped. In my MainWindow, which is a WindowEx, I am calling AppWindow.SetIcon.
Thank you. Especially @duckblaster : Your comment lead to the solution for most of the warnings just by adding a missing description on the obsolete attribute. An obsolete attribute without a description generates warning CS0612 which WinAppSDK doesn't suppress., but it will suppress CS0618 which is generated if you do have a description.
Unfortunately there appears to be a bug in the code generator for one of the warnings which it forgot to suppress - I'll log a bug in the WinUI repo for that: microsoft/microsoft-ui-xaml#10855
Going to close this for now, since I've addressed what I can, logged an issue in the WinUI repo with a proposed fix for the last warning, and provided a workaround above.
Activity
dotMorten commentedon Oct 23, 2025
The icon class in WinUI has issues with high-resolution icons, and have since been replaced by Microsoft's own icon methods. You can use the Window's icon methods: ie MyWindow.AppWindow.SetTitleBarIcon(...),
MyWindow.AppWindow.SetIcon(...)andMyWindow.AppWindow.SetTitleBarIcon(...)WinUIEx will generally deprecate features as the WinAppSDK offers new SDKs with the same features.
I'll look into updating the obsolete warning to make this more clear.
Jak3b0 commentedon Oct 23, 2025
Um... I seem to already be calling
SetIconon theAppWindow. Did I understood you correctly? 😄dotMorten commentedon Oct 23, 2025
You wrote
Window.SetIcon, notAppWindow.SetIcon. The one on AppWindow is part of the WinAppSDK and not part of WinUIEx and shouldn't give you an obsolete warning.duckblaster commentedon Oct 24, 2025
I'm getting the same warnings coming from
TaskBarIconinXamlTypeInfo.g.cswhen I use WindowEx, even though I am not setting it (I can do global replace forWindowExtoWindowand the only change is these warnings).I am not getting any warnings for
SystemBackdropdespite it also being marked obsolete, and the only difference seems to be whether theObsoleteattribute has a description, and whether there is anEditorBrowsable(EditorBrowsableState.Never)attribute.Jak3b0 commentedon Oct 24, 2025
Yes sorry, I mistyped. In my MainWindow, which is a WindowEx, I am calling AppWindow.SetIcon.
mfeingol commentedon Oct 24, 2025
I am seeing the same thing, despite not using the
Iconclass or callingSetIconanywhere in my WinUI app.\obj\x64\Debug\net9.0-windows10.0.26100.0\win-x64\XamlTypeInfo.g.cs(1070,38,1070,58): error CS0612: 'Icon' is obsolete
Address most compiler warnings from generated code reported in #247
dotMorten commentedon Oct 24, 2025
Thank you. Especially @duckblaster : Your comment lead to the solution for most of the warnings just by adding a missing description on the obsolete attribute. An obsolete attribute without a description generates warning
CS0612which WinAppSDK doesn't suppress., but it will suppressCS0618which is generated if you do have a description.Unfortunately there appears to be a bug in the code generator for one of the warnings which it forgot to suppress - I'll log a bug in the WinUI repo for that: microsoft/microsoft-ui-xaml#10855
dotMorten commentedon Oct 24, 2025
If you have an
.editorconfigfile, you can add the following to suppress it for now:dotMorten commentedon Oct 24, 2025
Going to close this for now, since I've addressed what I can, logged an issue in the WinUI repo with a proposed fix for the last warning, and provided a workaround above.
mfeingol commentedon Nov 13, 2025
Would it make sense to release a 2.9.1 including 7c10504?
dotMorten commentedon Nov 13, 2025
@mfeingol probably :-) However it won't fix them all because of the Microsoft bug. Can you use the workaround for now?
Suppress diagnostics CS0612 and CS0618
dotMorten commentedon Oct 27, 2026
This is now fixed in Windows App SDK 2.6.4: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/release-notes/windows-app-sdk-2-0?pivots=stable#version-264
PR: microsoft/microsoft-ui-xaml#11738