aspnetcore: Getting error in Linux OS with .Net Core 2.2 - The configured user limit (128) on the number of inotify instances has been reached

I am using .Net Core 2.2 for my web project. I got test cases which I am executing using dotnet vstest as part of CI pipeline in Linux docker. However the execution of test cases fails sometimes with error “The configured user limit (128) on the number of inotify instances has been reached.” However if I re-run, it works successfully. I am not sure what’s going wrong. I had a look at this post but I am not using JSON file in my Startup class, also I am calling build() only once in my Main method.

Error Message:

> OneTimeSetUp: Autofac.Core.DependencyResolutionException : An error
> occurred during the activation of a particular registration. See the
> inner exception for details. Registration: Activator = MvcRouteHandler
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler], Lifetime =
> Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership =
> OwnedByLifetimeScope ---> An error occurred during the activation of a
> particular registration. See the inner exception for details.
> Registration: Activator = ActionInvokerFactory (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionInvokerFactory],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator = IActionInvokerProvider[]
> (DelegateActivator), Services =
> [System.Collections.Generic.IEnumerable`1[[Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider,
> Microsoft.AspNetCore.Mvc.Abstractions, Version=2.2.0.0,
> Culture=neutral, PublicKeyToken=adb9793829ddae60]]], Lifetime =
> Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership
> = ExternallyOwned ---> An error occurred during the activation of a particular registration. See the inner exception for details.
> Registration: Activator = ControllerActionInvokerProvider
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider],
> Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator = ControllerActionInvokerCache
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator =
> DefaultActionDescriptorCollectionProvider (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An exception was thrown while
> invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.)   ---->
> Autofac.Core.DependencyResolutionException : An error occurred during
> the activation of a particular registration. See the inner exception
> for details. Registration: Activator = ActionInvokerFactory
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionInvokerFactory],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator = IActionInvokerProvider[]
> (DelegateActivator), Services =
> [System.Collections.Generic.IEnumerable`1[[Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider,
> Microsoft.AspNetCore.Mvc.Abstractions, Version=2.2.0.0,
> Culture=neutral, PublicKeyToken=adb9793829ddae60]]], Lifetime =
> Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership
> = ExternallyOwned ---> An error occurred during the activation of a particular registration. See the inner exception for details.
> Registration: Activator = ControllerActionInvokerProvider
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider],
> Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator = ControllerActionInvokerCache
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator =
> DefaultActionDescriptorCollectionProvider (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An exception was thrown while
> invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.) (See inner exception
> for details.)   ----> Autofac.Core.DependencyResolutionException : An
> error occurred during the activation of a particular registration. See
> the inner exception for details. Registration: Activator =
> IActionInvokerProvider[] (DelegateActivator), Services =
> [System.Collections.Generic.IEnumerable`1[[Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider,
> Microsoft.AspNetCore.Mvc.Abstractions, Version=2.2.0.0,
> Culture=neutral, PublicKeyToken=adb9793829ddae60]]], Lifetime =
> Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership
> = ExternallyOwned ---> An error occurred during the activation of a particular registration. See the inner exception for details.
> Registration: Activator = ControllerActionInvokerProvider
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider],
> Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator = ControllerActionInvokerCache
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator =
> DefaultActionDescriptorCollectionProvider (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An exception was thrown while
> invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.)   ---->
> Autofac.Core.DependencyResolutionException : An error occurred during
> the activation of a particular registration. See the inner exception
> for details. Registration: Activator = ControllerActionInvokerProvider
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider],
> Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator = ControllerActionInvokerCache
> (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator =
> DefaultActionDescriptorCollectionProvider (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An exception was thrown while
> invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.) (See inner exception
> for details.)   ----> Autofac.Core.DependencyResolutionException : An
> error occurred during the activation of a particular registration. See
> the inner exception for details. Registration: Activator =
> ControllerActionInvokerCache (ReflectionActivator), Services =
> [Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An error occurred during the
> activation of a particular registration. See the inner exception for
> details. Registration: Activator =
> DefaultActionDescriptorCollectionProvider (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An exception was thrown while
> invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.) (See inner exception
> for details.) (See inner exception for details.)   ---->
> Autofac.Core.DependencyResolutionException : An error occurred during
> the activation of a particular registration. See the inner exception
> for details. Registration: Activator =
> DefaultActionDescriptorCollectionProvider (ReflectionActivator),
> Services =
> [Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider],
> Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared,
> Ownership = OwnedByLifetimeScope ---> An exception was thrown while
> invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.) (See inner exception
> for details.)   ----> Autofac.Core.DependencyResolutionException : An
> exception was thrown while invoking the constructor 'Void
> .ctor(System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Abstractions.IActionDescriptorProvider],
> System.Collections.Generic.IEnumerable`1[Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorChangeProvider])'
> on type 'DefaultActionDescriptorCollectionProvider'. ---> The
> configured user limit (128) on the number of inotify instances has
> been reached. (See inner exception for details.)   ---->
> System.IO.IOException : The configured user limit (128) on the number
> of inotify instances has been reached.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 20 (7 by maintainers)

Most upvoted comments

use command export DOTNET_USE_POLLING_FILE_WATCHER=true And restart VsCode it will work

your linux docker must have this extra setup: echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p this will increase the amount of authorized instances as too many may be taken by something else

https://github.com/Legedric/ptmagic/issues/165

follow this for ubuntu

I found the following blog post that might help pinpoint the problem and solution. Hope it helps.

https://www.danieldevelops.com/inotify-watcher-dotnet-core

Alternative is to increase the inotify limit, which I have done until you (hopefully) fix the issue.

Just for reference for others. You can get your current inotify file watch limit by executing:

$ cat /proc/sys/fs/inotify/max_user_watches

You can set a temporary new limit with:

$ sudo sysctl -w fs.inotify.max_user_watches=16384

If you like to make your limit permanent use:

$ echo fs.inotify.max_user_watches=16384 | sudo tee -a /etc/sysctl.conf $ sudo sysctl -p

Thx for the great work. Love the PT Magic!

After fix restart your vs code

Hi, @Eilon Try to set up environment variable DOTNET_USE_POLLING_FILE_WATCHER=1