Skip to content

System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1 #179

@carstenh123

Description

@carstenh123

Hi,

I am using Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll version 4.1.0 in my web service project that is .net48 based.

After i have deployed my web service i get this file load exception in the event viewer when accessing the web service:

Faulting application name: csc.exe, version: 4.100.22.11411, time stamp: 0xb38fc9ae
Faulting module name: KERNELBASE.dll, version: 10.0.17763.2028, time stamp: 0x4569c786
Exception code: 0xe0434352
Fault offset: 0x0000000000039329
Faulting process id: 0x2dd4
Faulting application start time: 0x01dca6365e0cb0da
Faulting application path: C:\xyz\xyz\bin\roslyn\csc.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: 2eaf6326-bd27-47a2-aec3-ae9001aa314c
Faulting package full name:
Faulting package-relative application ID:

and:

Application: csc.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException
at System.MemoryExtensions.AsSpan(System.String)
at Roslyn.Utilities.CommandLineUtilities.SplitCommandLineIntoArguments(System.String, Boolean, System.Nullable1<Char> ByRef) at Microsoft.CodeAnalysis.CommandLine.BuildClient.GetCommandLineWindows(System.Collections.Generic.IEnumerable1<System.String>)
at Microsoft.CodeAnalysis.CommandLine.BuildClient.Run(System.Collections.Generic.IEnumerable`1<System.String>, Microsoft.CodeAnalysis.CommandLine.RequestLanguage, Microsoft.CodeAnalysis.CommandLine.CompileFunc, Microsoft.CodeAnalysis.CommandLine.CompileOnServerFunc)
at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore(System.String[])
at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[])

When i try to run the csc.exe as admin in a command prompt i get:
PS C:\xyz\xyz\bin\roslyn> .\csc.exe

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.MemoryExtensions.AsSpan(String text)
at Roslyn.Utilities.CommandLineUtilities.SplitCommandLineIntoArguments(String commandLine, Boolean removeHashComments, Nullable1& illegalChar) at Microsoft.CodeAnalysis.CommandLine.BuildClient.GetCommandLineWindows(IEnumerable1 args)
at Microsoft.CodeAnalysis.CommandLine.BuildClient.Run(IEnumerable`1 arguments, RequestLanguage language, CompileFunc compileFunc, CompileOnServerFunc compileOnServerFunc)
at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore(String[] args)
at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)

The provided System.Runtime.CompilerServices.Unsafe.dll in the bin\roslyn folder is version 5.0.20.51904.

I wonder why System.Runtime.CompilerServices.Unsafe.dll is not version 4.0.4.1.

Have any one else seen this issue or can help me fixing it?

Thanks in advance
C.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions