dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.62k stars 4.56k forks source link

Could not load file or assembly using Microsoft.Extensions.Configuration.Json #18461

Open Cheelax opened 7 years ago

Cheelax commented 7 years ago

Hi everybody, I'm working on a windows 10 IoT project where I want to use Microsoft.Extensions.Configuration.Json so I added it in my project.json in the dependencies:

"dependencies": { "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2", "System.Xml.XmlDocument": "4.0.1", "System.Xml.XPath.XDocument": "4.0.1", "Serilog": "2.2.1", "Serilog.Sinks.RollingFile": "2.2.0", "Microsoft.Extensions.Configuration.Json": "1.0.0" },

I can deploy my solution but I have this exception:

{"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.":"System.IO.FileSystem.Watcher, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}

I tried adding System.IO.FileSystem.Watcher to my dependencies in project.json but it didn't solve the problem...

It looks like this person has a similar problem: http://stackoverflow.com/questions/37365216/uwp-application-and-net-core-rc2-cannot-reference-netstandard1-4-packages

Somebody has an idea? Thank you

tarekgh commented 7 years ago

CC @ericstj @ianhays

ericstj commented 7 years ago

I take it this is a UAP app? FileSystem.Watcher isn't supported for UAP. The Windows APIs it needs to call are not available to UAP apps. You should have seen an error from NuGet after you added that to your project.

Here is what I see:

Error       System.IO.FileSystem.Watcher 4.0.0 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
Error       One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot).
...

Those errors mean that the package is not compatible with UAP.

tarekgh commented 7 years ago

@ericstj any idea if there is a version of Microsoft.Extensions.Configuration.Json package that can work in UAP? it looks from the thread System.IO.FileSystem.Watcher is just a problem because Microsoft.Extensions.Configuration.Json is referencing it.