Skip to content

DotNetFrameworkDependencies throws ArgumentNullException in static constructor #8560

@albahari

Description

@albahari

The static constructor of DotNetFrameworkDependencies throws an ArgumentNullException when FSharp.Compiler.Service doesn't have a disk presence. This occurs when FSharp.Compiler.Service.dll is loaded directly into memory with Assembly.Load(byte[]); for instance, as is the case if you're using Microsoft's new single-file executable deployment feature in .NET Core.

The problem is in this line of code:

let fSharpCompilerLocation =
        let location = Path.GetDirectoryName(typeof<TypeInThisAssembly>.Assembly.Location)

This evaluates to null when FSharp.Compiler.Service.dll doesn't have a disk presence, which then
causes an ArgumentNullException to be thrown when later calling Path.Combine:

let getDefaultFSharpCoreLocation = Path.Combine(fSharpCompilerLocation, getFSharpCoreLibraryName + ".dll")

The call to Path.Combine fails when fSharpCompilerLocation is null.

Note that this problem has just appeared in version 34 of FSharp.Compiler.Service. It did not occur in version 33.

Metadata

Metadata

Assignees

Labels

Area-FCSBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.Regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions