Skip to content

.NET SDK 5.0.200 and 5.0.104 can't load default styles of custom control #4414

@huoyaoyuan

Description

@huoyaoyuan

Update:
This has been fixed by .NET SDK 5.0.202 which is shipped with VS 16.9.4.

Confirmed that there's a problematic CsWinRT version included by SDK 5.0.104/200/201. Force downgrading it resolves the issue.

Workarounds
Option A: in your global.json:

{
  "sdk": {
    "version": "5.0.103",
    "rollForward": "disable"
  }
}

However, Windows Update can update your installed 5.0.103 SDK to 5.0.104, which is also buggy.

Option B: in your project file, the managed exe project:

<ItemsGroup>
  <!-- If you are targeting 18362 -->
  <FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.18362.13" />

  <!-- Or -->
  <!-- If you are targeting 19041 -->
  <FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.19041.13" />
</ItemsGroup>

.14 are the buggy verions.


Describe the bug
I'm surprised that my previously working app showing blank screen. After investigating with Live Visual Tree, the subtree of a templated control is totally empty. I compared with several commits and realized that the only difference should be .NET SDK update.

I'll try to get a repro later. You may also try to reproduce it yourself.
The control in a control library. It's default style is in a separated resource dictionary, merged by Generic.xaml. The control resource dictionary uses x:Bind and has code behind. When I set breakpoint in the code behind constructor, it's not invoked.

Version Info

NuGet package version:

[Microsoft.WinUI 3.0.0-preview3.201113.0]
[Microsoft.WinUI 3.0.0-preview4.210210.4]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions