-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssemblyFinder throw Exception in .Net5.0(RC2) SingleFile #239
Comments
Thanks for letting us know 👍 |
This seems to be related: dotnet/runtime#41265 @nblumhardt Do you think that it can be fixed in Serilog.Settings.Configuration? Currently this is the only thing preventing me from upgrading my SingleFile WinForms App from .NET Core 3.1 to .NET 5.0. Thanks! |
Hi @BalintBanyasz - thanks for the note. Yes, I'd guess there is some way to detect this situation and avoid a crash, here. I am short of time to investigate at the moment; if anyone encountering this has time to debug and propose a fix, that would be welcome. |
In the meantime, you can maybe provide your own implementation of |
tried implementing var functionDependencyContext = DependencyContext.Load(typeof(Startup).Assembly);
...
.ReadFrom.Configuration(configuration, "Serilog", dependencyContext: functionDependencyContext) but still getting hit with
|
Hi guys, the current workaround for .ReadFrom.Configuration(configuration, ConfigurationAssemblySource.AlwaysScanDllFiles) and place all external configuration assemblies to the "Using": [ "Serilog.Sinks.Console", "Serilog.Enrichers.Thread", ... etc ], I've added NotSupportedException handling in the PR and updated the documentation. |
any workaround for .net 5? |
@murugaratham sorry, I meant |
@skomis-mm yea, i am on .net 5 and i've tried
but i still get same error |
@murugaratham , interesting. Do you have any
Are the any stack frames between these 2 lines? |
The stack trace pasted was pretty much it |
var functionDependencyContext = DependencyContext.Load(typeof(Startup).Assembly);
...
.ReadFrom.Configuration(configuration, "Serilog", dependencyContext: functionDependencyContext) Is the |
@murugaratham just remove this line |
Seems working fine and I feel dumb |
Not sure if this is related, but when I build to single file for Centos7 ( the build is done on Mac ) The files are added to the publish folder as soon as I add Serilog.Settings.Configuration on my net50 project.
|
Another workaround is to set I have tested this with version Some additional info on the workaround can be found here - dotnet/runtime#44511 (comment) |
Would be nice to mention it in the readme. |
Unhandled exception. System.NotSupportedException: CodeBase is not supported on assemblies loaded from a single-file bundle.
at System.Reflection.RuntimeAssembly.get_CodeBase()
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.GetNormalizedCodeBasePath(Assembly assembly)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.GetDepsJsonPath(Assembly assembly)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadAssemblyContext(Assembly assembly, IDependencyContextReader reader)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
at Microsoft.Extensions.DependencyModel.DependencyContext.Load(Assembly assembly)
at Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault()
at System.Lazy
1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy
1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)at System.Lazy
1.CreateValue() at System.Lazy
1.get_Value()at Microsoft.Extensions.DependencyModel.DependencyContext.get_Default()
at Serilog.Settings.Configuration.Assemblies.AssemblyFinder.Auto()
at Serilog.ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration settingConfiguration, IConfiguration configuration, String sectionName, DependencyContext dependencyContext)
at Serilog.ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration settingConfiguration, IConfiguration configuration, DependencyContext dependencyContext)
at HostApp.Program.<>c.b__1_2(WebHostBuilderContext hosting, LoggerConfiguration logger)
at Serilog.SerilogWebHostBuilderExtensions.<>c__DisplayClass1_0.b__0(WebHostBuilderContext context, IServiceCollection collection)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass11_0.b__0(HostBuilderContext context, IServiceCollection builder)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at HostApp.Program.Main(String[] args)
The text was updated successfully, but these errors were encountered: