3

When I start debugging my app in a Linux Docker container, I get the exception when calling CreateHostBuilder(args).Build(). The code is part of a pretty new AspASP.NET Core MVC 3.1 project.

I saw the issue before and maybe fixed it removing an orphan file in a Views sub-folder. The problem seemed to come back after switching branches in git. It happened a third time after renaming a cshtml file in my project.

    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

Exception

System.IO.IOException
  HResult=0x00000026
  Message=Function not implemented
  Source=System.IO.FileSystem
  StackTrace:
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories(String directory, String expression, EnumerationOptions options)
   at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.Directory.EnumerateDirectories(String path)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
   at System.IO.FileSystemWatcher.RunningInstance..ctor(FileSystemWatcher watcher, SafeFileHandle inotifyHandle, String directoryPath, Boolean includeSubdirectories, NotifyFilters notifyFilters, CancellationToken cancellationToken)
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
   at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
   at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at FieldViewAdminHub.Program.Main(String[] args)

I Tried

  • Executing a Clean
  • Deleting obj and bin folders
  • Stopping the docker container explicitly
5
  • Andy I tried stepping the code and it just worked. Then I tried debugging again and it just worked. Aug 19, 2020 at 19:56
  • Is this is a docker compose project ? are you visual studio 2017 or 2019 ?
    – AnGG
    Aug 19, 2020 at 20:14
  • No, this is an asp.net-core-mvc project. I am just using Visual Studio's built-in debug in docker. Aug 19, 2020 at 20:35
  • Note: The issue came back after switching some files around, but if I roll-back the changes (using git reset), it's still crashing. Aug 19, 2020 at 20:36
  • I have noticed that this issue happens when i change file in the project directory without stopping the debugging first.
    – Riccardo
    Aug 28, 2020 at 12:57

3 Answers 3

3

Based on the answer by @AnGG, I just restarted Docker for Windows (I did not want to prune right now).

2
  • The error happened for the third time when I renamed a cshtml files and this did the trick immediately. Aug 21, 2020 at 20:05
  • 1
    I added a cshtml file manually (an editor template) and this error happened... I restarted Docker as well and it started working. Aug 24, 2020 at 4:02
1

Try ( be careful with those )

  1. stop all the running containers
  2. docker system prune ( be careful, this may remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes. )
  3. docker system prune -a ( be careful, this may remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes. )
  4. docker volume prune ( be careful, this may remove all volumes. )
  5. restart docker
  6. docker project clean
  7. delete bin and obj folders inside the project folder
  8. docker project rebuild

try to debug again

-1
public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            });


public Startup(IConfiguration configuration)
    {
        _configuration = configuration;
    }

Hi, Please try to add this right after your code. And write the second to Startup. It will be constructor. And one more thing, check your libraries and be sure to have configuration extension. I think your problem is your function don't have a mission. This way you are pathing your startup and having a default host. Basicly. Hope it works. Have a nice day.

1
  • These functions already exist in the code - they were part of the new-project template in vs2019. Aug 19, 2020 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.