Getting exeption "An error occurred while writing to logger(s)"

2

I found in my log-files following error:

An error occurred while writing to logger(s). Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)

In case of an exception occur, we are writing the details into a file in azure blob storage. One file per day. This exception doesn't occur everytime, just sometimes..

Does anybody know whats the problem? We're using following packages:

<PackageReference Include="AspNet.Security.OAuth.Introspection" Version="1.0.0" />
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.1.5" />
<PackageReference Include="OpenIddict" Version="1.0.0-rc2-0784" />
<PackageReference Include="OpenIddict.Core" Version="1.0.0-rc2-0784" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-rc2-0784" />
<PackageReference Include="OpenIddict.Mvc" Version="1.0.0-rc2-0784" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.1.5" />
<PackageReference Include="System.Text.Encodings.Web" Version="4.3.1" />
<PackageReference Include="Swashbuckle" Version="6.0.0-beta902" />
<PackageReference Include="Serilog" Version="2.6.0" />
<PackageReference Include="Serilog.Sinks.AzureTableStorage" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />

and

<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.5" />
<PackageReference Include="System.Text.Encodings.Web" Version="4.3.1" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
<PackageReference Include="OpenIddict" Version="1.0.0-rc2-0784" />
<PackageReference Include="System.Net.Security" Version="4.3.1" />

and

<PackageReference Include="WindowsAzure.Storage" Version="7.2.1" />

Thanks for your help! :)

c#
azure
asp.net-core
azure-blob-storage
asked on Stack Overflow Feb 16, 2018 by everydayXpert

1 Answer

2

There is a similar thread which has happened in before here There are several types of solutions depending on your environment.

Some users were able to resolve the issue by doing the following:

Deleting \bin and \obj folders before publishing
Deleting my folder that I publish to
Resetting IIS
Making sure that the ApplicationPoolIdentity's .NET CLR version is set to "No Managed Code"

User contributions licensed under CC BY-SA 3.0