Search code examples
c#.netwpfazure

Could not load file or assembly "System.Runtime" error in Windows Server Env


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. 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. Only one dependency includes this assembly and it's compatible to .NET 6. 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. What does this file mean?
  3. Why the error does not exist on my local system windows 11?

Update 1:

After some experiments, I am able to isolate the problem in a third party tool Actipro. There are two ways to integrate this tool. The first way which I used is installing the software and reference the assemblies. It worked fine. Since we are moving to Azure, I had to switch to the second way which is their Nuget Package. It worked fine on my local system but not on the Pipeline/VM. Today I uninstalled my local installation of Actipro and I am seeing the same error on my local machine. So I guess this problem is not related to the VM. Is there a way that a Nuget package reading license info from local storage? Here is a link to their official guide: https://www.actiprosoftware.com/docs/controls/wpf/licensing


Solution

  • The problem is caused by an existing .licx file, which is no longer supported by Actipro .NET 6. After removing the file, it works without issue.