SHARE
TWEET

Untitled

a guest Jul 19th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Unhandled Exception: System.IO.IOException: Invalid argument
  2.   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry()
  3.   at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
  4.   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)
  5. message repeated 5 times: [    at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName)]
  6.   at System.IO.FileSystemWatcher.RunningInstance..ctor(FileSystemWatcher watcher, SafeFileHandle inotifyHandle, String directoryPath, Boolean includeSubdirectories, NotifyFilters notifyFilters, CancellationToken cancellationToken)
  7.   at System.IO.FileSystemWatcher.StartRaisingEvents()
  8.   at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
  9.   at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
  10.   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
  11.   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
  12.   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
  13.   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
  14.   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
  15.   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
  16.   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
  17.   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
  18.   at LiveServer.WebApi.Program.BuildWebHost(String[] args) in /mnt/c/Workspace/Playground/LiveServer/LiveServer.WebApi/Program.cs:line 15
  19.   at LiveServer.WebApi.Program.Main(String[] args) in /mnt/c/Workspace/Playground/LiveServer/LiveServer.WebApi/Program.cs:line 11
  20.      
  21. public class Program
  22.  {
  23.     private static Logger logger = LogManager.GetLogger("Startup");
  24.  
  25.     public static void Main(string[] args)
  26.     {
  27.         BuildWebHost(args).Run();
  28.     }
  29.  
  30.     public static IWebHost BuildWebHost(string[] args)
  31.     {
  32.         try
  33.         {
  34.             return WebHost.CreateDefaultBuilder(args)
  35.                 .UseUrls(GetWebApiUrl())
  36.                 .UseKestrel()
  37.                 .UseStartup<Startup>()
  38.                 .Build();
  39.         }
  40.         catch (Exception ex)
  41.         {
  42.             var msg = $"Error while starting WebApi: Error - {ex.Message} Inner Error - {ex.InnerException.Message} Stack - {ex.StackTrace} InnerStack {ex.InnerException.Message}";
  43.             logger.Fatal(msg);
  44.             throw new Exception(msg);
  45.         }
  46.  
  47.     }
  48.  
  49.     private static string GetWebApiUrl()
  50.     {
  51.         var assemblyPathInfo = new FileInfo(Assembly.GetEntryAssembly()?.Location ?? throw new InvalidOperationException());
  52.         var configurationFilePath = Path.Combine(assemblyPathInfo.DirectoryName, "appsettings.json");
  53.  
  54.         var config = new ConfigurationBuilder().AddJsonFile(configurationFilePath, optional: false).Build();
  55.         var webApiUrl = config["WebApi:URL"];
  56.         return webApiUrl;
  57.     }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top