Could not load InplaceStringBuilder while creating WebHost from script

344 views Asked by At

This script, which creates a web-server to serve a static static files, compiles and starts but unable to serve requests.

dotnet script server.csx

#r "nuget: Microsoft.AspNetCore, 2.2.0"
#r "nuget: Microsoft.AspNetCore.StaticFiles, 2.2.0"
#r "nuget: Microsoft.Extensions.Primitives, 5.0.0"

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

Microsoft.AspNetCore.WebHost
    .CreateDefaultBuilder(Array.Empty<string>())
    .Configure(config => config.UseStaticFiles())
    .UseWebRoot(".").Build().Run();

Every request fails with

fail: Microsoft.AspNetCore.Server.Kestrel[0]
      Heartbeat.OnHeartbeat
      System.TypeLoadException: Could not load type 'Microsoft.Extensions.Primitives.InplaceStringBuilder' from assembly 'Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
         at Microsoft.Net.Http.Headers.DateTimeFormatter.ToRfc1123String(DateTimeOffset dateTime, Boolean quoted)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.DateHeaderValueManager.SetDateValues(DateTimeOffset value)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.Heartbeat.OnHeartbeat()

There are some solutions but the ones I've tried either did not work or not applicable it is script.

0

There are 0 answers