0
votes

I'm trying to use FileSystemWatcher class in coreclr project on Ubuntu but I'm getting following exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem.Watcher, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

my project.json file:

{
"version": "1.0.0-*",
"compilationOptions": {
    "emitEntryPoint": true
},

"dependencies": {
    "Microsoft.NETCore.Runtime": "1.0.1-beta-*",
    "System.IO": "4.0.11-beta-*",
    "System.IO.FileSystem.Watcher": "4.0.0-beta-*",
    "System.Console": "4.0.0-beta-*",
    "System.Runtime": "4.0.21-beta-*"
},

"frameworks": {
    "dnxcore50": { }
}
}

and Program.cs:

using System;
using System.IO;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {            
            using (var watcher = new FileSystemWatcher("."))
            {
                Console.WriteLine("Watcher created!");    
            }
        }
    }
}

What am I doing wrong?

PS. .NET Core installed according to instructions from this site: https://dotnet.github.io/getting-started/

1
Try running dnu restore in directory, does it succeed? - Pavel Krymets
@PavelKrymets: that's how I've started - tried dotnet restore, dotnet run. There's no dnu available on my console, but I thought that 'dotnet' it's just an alias to dnu tool. There's no any errors or warnings during restore, everything seems OK. - krlm
Missed that you were using dotnet, i'll check again - Pavel Krymets
Try removing -beta version part in your dependencies to be "4.0.0-* etc. - Pavel Krymets
@PavelKrymets: no difference - the same result after dotnet restore, dotnet run. - krlm

1 Answers

0
votes

Here's a minimal version of the project.json that works fine with the above Program.cs file on my Ubuntu VM:

{
  "dependencies": {
    "System.IO.FileSystem.Watcher": "4.0.0-beta-23516"
  },
  "frameworks": {
    "dnxcore50": {
      "dependencies": {
        "System.Console": "4.0.0-beta-23516"
      }
    }
  }
}