Could not load file or assembly "System.Runtime" on Windows Server

zhangjinzhou 20 Reputation points
2024-04-12T21:44:36.36+00:00

I migrated a WPF project from .NET Framework to .NET 6 which builds fine on my local system (windows 11). However when I moved forward to Azure pipeline, we got this error and it can be replicated on a Windows Server 2022 VM. There are multiple .NET projects in the solution. This is the only project with this issue.

The full error is

Error LC0000 'Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)' ProAnalysisUI C:\...\ProAnalysisUI\LC 1

There are several points confuse me:

  1. The error shows missing assembly but "System.Runtime" is not directly used in this project. How can I trace where the assembly cause this error?
  2. It shows the error occurs in file LC which I don't see it directly in the file structure. I searched it and it seems the file is related to licenses. But the licenses of what?
  3. Why the error does not exist on my local system windows 11?
  4. Last, what could be a solution?
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,674 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,155 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 48,486 Reputation points
    2024-04-15T01:42:12.8866667+00:00

    First thought is that NET 6 isn't installed on the target machine?

    Second thought is that LC0000 sounds like the license compiler which is used for licensed third party components. Are you using third party components and are they properly licensed and have you followed the licensing requirements to get the license deployed on the target machine?

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful