Skip to content

[dotnet-sdk-9.0.100-rc.2.24474.11] paint.netcore build with errors about elements from Microsoft.Windows.SDK.NET are not found #43707

@Junjun-zhao

Description

@Junjun-zhao

Application Name: paint.netcore
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-rc.2.24474.11
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2261861

Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.300: Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.1.24452.12: Pass
3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.2.24470.13: Fail
4). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.2.24474.11: Fail

Description :
When build the 3rd party application paint.net with the latest .NET 9 sdk, it failed with errors:

CS0103  The name 'DispatcherQueueController' does not exist in the current context
CS0103  The name 'DispatcherQueue' does not exist in the current context
CS0103  The name 'DispatcherQueuePriority' does not exist in the current context
CS0103  The name 'DisplayInformationInterop' does not exist in the current context
CS0234  The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
CS0234  The type or namespace name 'System' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
CS0234  The type or namespace name 'Foundation' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
CS0246  The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
CS0246  The type or namespace name 'DispatcherQueue' could not be found (are you missing a using directive or an assembly reference?)
CS0246  The type or namespace name 'TypedEventHandler<,>' could not be found (are you missing a using directive or an assembly reference?)
CS0246  The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
CS1660  Cannot convert anonymous method to type 'TypedEventHandler<Graphics.Display.DisplayInformation, object>?' because it is not a delegate type

Minimal Repro Steps: (Demo attached:ConsoleDemo.zip)
The machine has dotnet-sdk-9.0.100-rc.2.24474.11 installed.
1.Create a .NET 8 Console application.
2. Update the csproj file with following changes:

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<WindowsSdkPackageVersion>10.0.26100.1</WindowsSdkPackageVersion>
</PropertyGroup>

  1. Add a AdvancedColorKind.cs file with following code:
using System;
using Windows.System;
using Windows.Foundation;
using Windows.Graphics.Display;
using Windows.Media.Miracast;
 
namespace ConsoleApp1
{
    using DisplayInformationWinRT = global::Windows.Graphics.Display.DisplayInformation;
    public class Test
    {
        private readonly DispatcherQueue dispatcherQueue;
        DispatcherQueuePriority dqp = DispatcherQueuePriority.Low;
        private static readonly ThreadLocal<DispatcherQueueController> perThreadController;
        public void TestMethod()
        {
            TypedEventHandler<DisplayInformationWinRT, object>? advancedColorInfoChangedHandler = null;
            advancedColorInfoChangedHandler =
                delegate (DisplayInformationWinRT displayInformation, object _)
                {  };
        }
    }

    internal enum AdvancedColorKind
    {
        HighDynamicRange = global::Windows.Graphics.Display.AdvancedColorKind.HighDynamicRange,
        StandardDynamicRange = global::Windows.Graphics.Display.AdvancedColorKind.StandardDynamicRange,
        WideColorGamut = global::Windows.Graphics.Display.AdvancedColorKind.WideColorGamut
    }
}

  1. Open command prompt window and navigate to .sln file folder.
  2. Run "dotnet new globaljson" and make sure the SDK version assigned in global.json file is 9.0.100-rc.2.24474.11.
{
  "sdk": {
"version": "9.0.100-rc.2.24474.11"
  }
}
  1. Build the project.

Expected Result:
Build Successful.

Actual Result:
Build with following errors:

Please refer to Binlog and Compiler log from msbuild_binlog complog.zip

CS0246 

The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
CS0103 The name 'DispatcherQueuePriority' does not exist in the current context
CS0246 The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'DispatcherQueue' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'DispatcherQueuePriority' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
CS0246 The type or namespace name 'TypedEventHandler<,>' could not be found (are you missing a using directive or an assembly reference?)
CS0400 The type or namespace name 'Windows' could not be found in the global namespace (are you missing an assembly reference?)
CS0400 The type or namespace name 'Windows' could not be found in the global namespace (are you missing an assembly reference?)
CS0400 The type or namespace name 'Windows' could not be found in the global namespace (are you missing an assembly reference?)
CS0400 The type or namespace name 'Windows' could not be found in the global namespace (are you missing an assembly reference?)
CS1660 Cannot convert anonymous method to type 'TypedEventHandler<Windows.Graphics.Display.DisplayInformation, object>?' because it is not a delegate type

Findings:
We found all the namespaces/types in errors come from Microsoft.Windows.SDK.NET. When using dotnet-sdk-9.0.100-rc.2.24474.11 to build the app, the "Windows" namespace is not be recognized by compiler and the elements from "Windows" namespaces are also cannot be recognized.

App Repro Steps on repro machine:(dotnet-sdk-9.0.100-rc.2.24474.11 installed)

Please get the repro machine information from DevDiv bug:

  1. Run command "dotnet build" in C:\Users\Test01\Desktop\paint.net\PaintDotNet.

Expected Result:
Build successfully.

Actual Result:
Build failed with errors:

The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The name 'DispatcherQueue' does not exist in the current context
The name 'DispatcherQueuePriority' does not exist in the current context
The name 'DisplayInformationInterop' does not exist in the current context
The name 'DispatcherQueueController' does not exist in the current context
The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'System' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'Foundation' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'Graphics' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'System' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'System' does not exist in the namespace 'Windows' (are you missing an assembly reference?)
The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueue' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'TypedEventHandler<,>' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'TypedEventHandler<,>' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DispatcherQueueController' could not be found (are you missing a using directive or an assembly reference?)
Cannot convert anonymous method to type 'TypedEventHandler<Graphics.Display.DisplayInformation, object>?' because it is not a delegate type

Dotnet Info:

.NET SDK:
 Version:           9.0.100-rc.2.24474.11
 Commit:            315e1305db
 Workload version:  9.0.100-manifests.82e6a096
 MSBuild version:   17.12.0-preview-24473-03+fea15fbd1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-rc.2.24474.11\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0-rc.2.24473.5
  Architecture: x64
  Commit:       990ebf52fc

.NET SDKs installed:
  10.0.100-rc.2.24474.11 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-WindowsSDKIssues related to the Windows SDK and how it is included and managed in the .NET SDKuntriagedRequest triage from a team member

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions