Skip to content

Getting "'Icon' is obsolete" warning on build #247

Closed

Description

@Jak3b0

Hi,

Since I've updated to the version 2.9.0 version, I'm having the following warning when building:

warning CS0612: 'Icon' is obsolete

I've try changing the calls to Window.SetIcon for Window.SetTitleBarIcon but I get the same result.

I've not seem any release notes regarding this. Is there something I can do to fix that?

Thank you!

Activity

  1. dotMorten commented on Oct 23, 2025

    @dotMorten
    Owner

    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.

  2. Jak3b0 commented on Oct 23, 2025

    @Jak3b0
    Author

    Um... I seem to already be calling SetIcon on the AppWindow. Did I understood you correctly? 😄

  3. dotMorten commented on Oct 23, 2025

    @dotMorten
    Owner

    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.

  4. duckblaster commented on Oct 24, 2025

    @duckblaster

    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).

    Image

    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.

    Image
    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
    
  5. Jak3b0 commented on Oct 24, 2025

    @Jak3b0
    Author

    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.

  6. mfeingol commented on Oct 24, 2025

    @mfeingol

    I am seeing the same thing, despite not using the Icon class or calling SetIcon anywhere 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

    #pragma warning disable 0618  //   Warning on Deprecated usage
                _typeTable[362] = typeof(global::WinUIEx.Icon);
    #pragma warning restore 0618
  7. dotMorten commented on Oct 24, 2025

    @dotMorten
    Owner

    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

  8. added
    External bugBugs caused by other dependencies
    and removed
    documentationImprovements or additions to documentation
    on Oct 24, 2025
  9. dotMorten commented on Oct 24, 2025

    @dotMorten
    Owner

    If you have an .editorconfig file, you can add the following to suppress it for now:

    # Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/10855
    [XamlTypeInfo.g.cs]
    dotnet_diagnostic.CS0612.severity = none
    dotnet_diagnostic.CS0618.severity = none
    
  10. dotMorten commented on Oct 24, 2025

    @dotMorten
    Owner

    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.

  11. mfeingol commented on Nov 13, 2025

    @mfeingol

    Would it make sense to release a 2.9.1 including 7c10504?

  12. dotMorten commented on Nov 13, 2025

    @dotMorten
    Owner

    @mfeingol probably :-) However it won't fix them all because of the Microsoft bug. Can you use the workaround for now?

  13. dotMorten commented on Oct 27, 2026

    @dotMorten
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    External bugBugs caused by other dependencies

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions