Runtime: [Recursive resource lookup bug] on runtime 2.0.4 with NLog.Web.AspNetCore

Created on 12 Jan 2018  路  6Comments  路  Source: dotnet/runtime

According to dotnet/runtime#23357, this bug should be already fixed, but when I publish a win10-x64 exe program, I get this exception.

Reproduce:

  1. add <PropertyGroup><RuntimeIdentifier>win10-x64</RuntimeIdentifier></PropertyGroup> to .csproj
  2. nuget install NLog.Web.AspNetCore 4.5.0-rc2
  3. WebHostBuilder UseNLog().ConfigureLogging(c => c.ConfigureNLog("nlog.config"))
  4. cmd dotnet publish -r win10-x64 or VS publish
  5. execute netcoreapp2.0\win10-x64\publish\test.exe

Exception:

Assert Failure
Expression: [Recursive resource lookup bug]
Description: Infinite recursion during resource lookup within System.Private.CoreLib.  This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names.  Resource name: ArgumentNull_Generic
Stack Trace:
   at System.SR.InternalGetResourceString(String key)
   at System.SR.GetResourceString(String resourceKey, String defaultString)
   at System.ArgumentNullException..ctor(String paramName)
   at System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly assembly)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
   at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at System.SR.InternalGetResourceString(String key)
   at System.SR.GetResourceString(String resourceKey, String defaultString)
   at System.ArgumentNullException..ctor(String paramName)
   at System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly assembly)
   at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
   at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at System.SR.InternalGetResourceString(String key)
   at System.SR.GetResourceString(String resourceKey, String defaultString)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at NLog.Extensions.Logging.ConfigureExtensions.ConfigureHiddenAssemblies()
   at NLog.Extensions.Logging.ConfigureExtensions.AddNLog(ILoggingBuilder factory, NLogProviderOptions options)
   at NLog.Web.AspNetExtensions.ConfigureNLog(ILoggingBuilder builder, String configFileName)
   at test.Program.<>c.<BuildWebHost>b__1_0(ILoggingBuilder c) in E:\dev\testBug\Program.cs:line 27
   at Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging(IServiceCollection services, Action`1 configure)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.<>c__DisplayClass6_0.<ConfigureLogging>b__0(IServiceCollection collection)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at test.Program.BuildWebHost(String[] args) in E:\dev\testBug\Program.cs:line 28
   at test.Program.Main(String[] args) in E:\dev\testBug\Program.cs:line 20
area-System.Runtime

Most helpful comment

The default runtime for standalone apps appears to be 2.0.0 and it's running against that, which doesn't contain the fix. For standalone apps it's necessary to set this attribute in the .csproj to reference a specific version:

<PropertyGroup>
  <RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
</PropertyGroup>

Or <RuntimeFrameworkVersion>2.0.*</RuntimeFrameworkVersion> to target the latest published 2.0.x runtime.

All 6 comments

@kouvel this looks the same issue you have fixed before which I expect it is fixed.

@kouvel I have marked the issue as 2.0.x till we figure out if there is a real problem and need to service 2.0.

@kouvel?

Sorry I'll be taking a look at this soon

I'm able to repro it, seems to happen only from the publish directory, taking a closer look

The default runtime for standalone apps appears to be 2.0.0 and it's running against that, which doesn't contain the fix. For standalone apps it's necessary to set this attribute in the .csproj to reference a specific version:

<PropertyGroup>
  <RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
</PropertyGroup>

Or <RuntimeFrameworkVersion>2.0.*</RuntimeFrameworkVersion> to target the latest published 2.0.x runtime.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omajid picture omajid  路  3Comments

bencz picture bencz  路  3Comments

jamesqo picture jamesqo  路  3Comments

noahfalk picture noahfalk  路  3Comments

jzabroski picture jzabroski  路  3Comments