Wpf: MC1000: Unknown build error Could not find assembly System.Web

Created on 24 Feb 2020  路  5Comments  路  Source: dotnet/wpf

  • .NET Core Version: tried both with SDK version 3.1.102 and 3.0.103
  • Windows version: 1809 Build 07763.973
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No

    Cannot build Wpf project using dotnet cli:
    I have added a global.json config file as follows:

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

With this the solution does build when using Visual Studio but when I build using the command line (dotnet build mySolution.sln) it fails with the below error.

If I change to use the latest SDK (3.1.102) it fails with the same error in both VS and on the command line. VS version is 16.4.5

Actual behavior:
C:\Program Files\dotnet\sdk\3.0.103\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(243,9): error MC1000: Unknown build error, 'Could not find assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.' [C:\dev\src\mySol\WpfAdditions\Shared.WpfAdditions.csproj]

Seems quite similar to #2274 just for a different assembly, not sure if it is basically the same issue.

Expected behavior:
Project builds correctly.

issue-type-bug needs-author-feedback

Most helpful comment

The workaround seems to be to put this in the csproj:

  <ItemGroup>
    <!-- Workaround for https://github.com/dotnet/wpf/issues/2648#issuecomment-635674683 -->
    <Reference Include="System.Web" />
  </ItemGroup>

All 5 comments

Can you share a repro project that can be used to investigate this ? Something small/self-contained that picks out the essential characteristics of the project that is affected by this bug would be nice. Chances are good that the NuGet references are the key.

/cc @rladuca, @nguerrera

Do you still have this problem when building against the latest .NET Core 3.1 SDK (3.1.103 or 3.1.201)?

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions!

I'm getting this on a small .NET Framework 4.8 WPF class library when I hand-convert it from legacy csproj to SDK-style csproj. SDK version is 3.1.300.

C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MC1000: Unknown build error, 'Could not find assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.'

It goes away when I remove the package reference to the DevExpress library:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="DevExpress.Wpf.Grid" Version="20.1.3" />
  </ItemGroup>

</Project>

Obviously this may not be your problem, but any tips to take back to DevExpress would be great.

The workaround seems to be to put this in the csproj:

  <ItemGroup>
    <!-- Workaround for https://github.com/dotnet/wpf/issues/2648#issuecomment-635674683 -->
    <Reference Include="System.Web" />
  </ItemGroup>
Was this page helpful?
0 / 5 - 0 ratings