Skip to content

Microsoft.WinFX.targets Unknown build error Could not find assembly 'mscorlib' #3183

Closed

Description

@nzain
  • .NET Core Version: Version: 3.1.301, Commit: 7feb845744
    Base Path: C:\Program Files\dotnet\sdk\3.1.301
    Host (useful for support): Version: 3.1.5, Commit: 65cd789777
  • Windows version: Win 10 (1909) 10.0.18363
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Not when creating a classic WPF full Framework project
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? no, dotnet build fails (without VS being involved)

Problem description:
WPF core app doesn't build when adding a direct <Reference .../> to an old .Net 2.0 framework dll.
(Why would you do that? Expensive, proprietary dll from 3rd party, we can't live without it, author has retired)

Actual behavior:
dotnet build fails with

C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9):
error MC1000: Unknown build error, 'Could not find assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.' [D:\Downloads\DotnetWpfCoreProblem\DotnetWpfCoreProblem.csproj]

Expected behavior:
It builds fine.

Minimal repro:
Create a new WPF core project: dotnet new wpf which will target netcoreapp3.1 at the time of writing.
Add a library reference to an old .Net Framework 2.0 WinCE library. Something like

<Reference Include="SomethingOld" HintPath="SomethingOld.dll" />

Try to build. Unfortunately I can't publish the proprietary dll here. It is built for .Net Framework 2 with WinCE compatibility.

Related Issues
I found similar topics where the build failed with the same error (mscorlib not found), but they seem to be resolved.
#1451
#2274

Activity

  1. added
    Bug
    on Jun 29, 2020
  2. added this to the 5.0.0 milestone on Jun 29, 2020
  3. fabiant3 commented on Jun 29, 2020

    @fabiant3
    Contributor

    @nzain - could you provide an isolated repro? (just the metadata from the assembly/ildasm)

  4. nzain commented on Jun 29, 2020

    @nzain
    Author

    Not sure what exactly that should be. Tomorrow, I'll add the project+output (if anything was generated) except for that proprietary lib.

  5. nzain commented on Jun 30, 2020

    @nzain
    Author

    dotnet wpf issue 3183.zip

    @fabiant3 Attached is everything that was generated so far. bin is empty (as expected) but hopefully you find what you're looking for in obj. If not, please explain how to get the required data.

  6. wldevries commented on Aug 6, 2020

    @wldevries

    I'm not sure how this relates to what I'm experiencing, but my WPF builds produce the exact same build error in the following scenario:

    • Empty Microsoft.NET.Sdk.WindowsDesktop project targeting net47. Reproduce by creating a NET Core WPF project and change the target to net47
    • PackageReference to CommonServiceLocator 1.3.0

    This is a tiny repro from one of our products that depends on an older version of Prism that uses CommonServiceLocator. We updated all of our NET Framework projects to the new Microsoft.NET.Sdk project system, which might not have been smart in hindsight.

  7. franchyd commented on Aug 6, 2020

    @franchyd

    @wldevries If you just updated Visual Studio you are more likely hitting this: dotnet/sdk#12710

  8. ryalanms commented on Aug 24, 2020

    @ryalanms
    Member

    This should be fixed in 16.7.1 and 3.1.401. Please reactivate if you see it again. Thanks!

  9. nzain commented on Aug 25, 2020

    @nzain
    Author

    @ryalanms I guess you talk about msbuild 16.7.1? I have dotnet SDK 3.1.401 installed (and the current 5.0 preview), but my msbuild is 16.7.0-preview-20360-03+188921e2f. The github msbuild releases https://github.com/dotnet/msbuild/releases are outdated. Where can I get version 16.7.1?

    Just to clarify, the issue is not resolved for me right now.

  10. nzain commented on Sep 3, 2020

    @nzain
    Author

    This issue is not fixed for me.

    The latest dotnet SDK 5.0.100-preview.8.20417.9 comes with Microsoft (R) Build Engine version 16.8.0-preview-20414-02+a55ce4fbb, but the issue is unchanged: mscorlib, Version=2.0.0.0 is not found.

    C:\Program Files\dotnet\sdk\5.0.100-preview.8.20417.9\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(240,9):
    error MC1000: Unknown build error, 'Could not find assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac'. 
    Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.'
    
  11. nzain commented on Sep 3, 2020

    @nzain
    Author

    Switching the TargetFramework to net5.0 doesn't make a difference.
    @ryalanms commented Please reactivate, if you see it again. but I cannot change the ticket status.

  12. ghost locked as resolved and limited conversation to collaborators on Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions