Open sasha-khadasevich opened 3 years ago
Yep same thing happens with my minimal repro. If anyone interested I can upload it(minimal repro) to github
I'm using a workaround like this
var sinks = builder.Configuration.GetSection("Serilog:Using").Get<string[]>();
var sinkAssemblies = sinks?.Select(sink => Assembly.LoadFrom($"{sink}.dll")).ToArray();
var configurationReaderOptions = sinkAssemblies != null && sinkAssemblies.Length > 0
? new ConfigurationReaderOptions(sinkAssemblies) { SectionName = "Serilog" }
: new ConfigurationReaderOptions() { SectionName = "Serilog" };
builder.Host
.UseSerilog((context, services, configuration) => configuration
.ReadFrom.Configuration(context.Configuration, configurationReaderOptions)
.ReadFrom.Services(services), preserveStaticLogger: false, writeToProviders: false);
Unable to load dynamically .dll to .asp net core app.
Steps to reproduce: -create default asp net core web api app and add Serilog.AspNetCore and Serilog.Settings.Configuration packages -update CreateHostBuilder
-copy paste Serilog.Sinks.Grafana.Loki.dll (for example) to bin\Debug\netcoreapp3.1 -add Grafana.Loki configuration to appSettings.json
In the result I have exception: System.IO.FileNotFoundException: 'Could not load file or assembly 'Serilog.Sinks.Grafana.Loki, Version=7.0.2.0, Culture=neutral, PublicKeyToken=e33b67d3bb5581e4'. The system cannot find the file specified.'