Code Works in LINQPad 5 But Fails in LINQPad6

Attached code works in LINQPad 5 but not in LINQPad 6. I was just trying to do some logging with serilog.

LINQPad 6 fails with error : "Could not find file 'C:\Users\******\AppData\Local\LINQPad\6.3.3\ProcessServer\3.0.0-x64\LINQPad6.Query.deps.json'"



Packages used



code

void Main() { var configuration = new ConfigurationBuilder() .SetBasePath(Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath))) .AddJsonFile("appsettings.json") .Build(); var logger = new LoggerConfiguration() .ReadFrom.Configuration(configuration) .CreateLogger(); logger.Error("Hello, world!"); }

Comments

  • I don't know why serilog requires that file. I guess I could get LINQPad to create a dummy file automatically for the sake of serilog.

    In the meantime, you could create a similar file yourself:
    {
      "runtimeTarget": {
        "name": ".NETCoreApp,Version=v3.0",
        "signature": ""
      },
      "compilationOptions": {},
      "targets": {
        ".NETCoreApp,Version=v3.0": {
          "LINQPad6.Query/1.0.0": {
            "runtime": {
              "LINQPad6.Query.dll": {}
            }
          }
        }
      },
      "libraries": {
        "LINQPad6.Query/1.0.0": {
          "type": "project",
          "serviceable": false,
          "sha512": ""
        }
      }
    }
  • @JoeAlbahari FWIW it looks like this is serilog's ReadFrom.Configuration that accepts a DependencyContext (from Microsoft.Extensions.DependencyModel) and if one isn't specified, uses DependencyContext.Default - when that's generated, it tries to figure out the assemblies based on ambient context which then hits this error as it assumes the deps.json exists.

    You can get the same error just by doing a C# statement of "var context = DependencyContext.Default;" with a single nuget reference to Microsoft.Extensions.DependencyModel.

    From an API perspective, AFAICT another alternative would be to explicitly build the DependencyContext being passed in to serilog's ReadFrom.Configuration so that it wouldn't attempt to build the default one.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!