0

When I trying to use LoadFromEnumerable to load my dataset which is implemented as List I got the following error (as mentioned in the title)

Could not load file or assembly 'Microsoft.ML.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified

I have updated to the latest version of ML.net packages but I still not find the documentation of Microsoft.ML.Api

var mlContext = new Microsoft.ML.MLContext();
var trainingData = mlContext.Data.LoadFromEnumerable(dataset);

EDIT

Error Message

Lau Chun Hong
  • 61
  • 1
  • 3
  • Can you walk us through the steps to reproduce this? So you open Visual Studio, New Project, Console Application, then you add a nuget package I guess? And then you paste those two lines in the main method and compile? And it compiles and then crashes with the error above? Or did you do something else? – nvoigt Aug 22 '19 at 09:27
  • Double check that you're targeting x64 in your project, as well. – Jon Aug 22 '19 at 09:45
  • 1
    Yes just like what you mentioned. Actually I got my data from database by connection string which may cause the problems. However, I try to follow this example: https://learn.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/load-data-ml-net#load-data-from-other-sources but I still got the same error – Lau Chun Hong Aug 23 '19 at 07:30
  • yes targeting x64 – Lau Chun Hong Aug 23 '19 at 07:42

2 Answers2

2

Had the same error with a classic/old "Windows Forms App (.NET Framework)".
Needed 1 1/2 days to figure out how to solve it. :-(

Finally I solved it and would like to share it:

  1. Select your program -> right mouse click -> "Properties" -> "Build" tab
    -> Two things to do here:

    1a) Set "Platform target" to "x64".

    1b) Click "Advanced" button at the bottom and check whether the "Language Version" contains minimum "C#7.1".
    But set "Language Version" to "C# latest major version (default)".

  2. Read this careful:
    Select "References" of your program -> right mouse click
    -> "Migrate packages.config to PackageReference...".
    Follow the wizard ...

The really bad thing is that the context menu entry "Migrate packages.config to PackageReference..." is only available in case a NuGet package is already added to your program!

So in case you get the above error at run time
but this context menu entry is not shown
install a dummy NuGet package of your choice (prefer a small one!).
Follow then step 2.
Remove then the prior installed "dummy NuGet package"
(Select therefore "References" of your program -> right mouse click -> "Manage NuGet Packages" ...)

Hope this helps someone!

V. Gedace
  • 23
  • 6
0

Microsoft.ML.Api was an old assembly name that has been removed. Can you ensure all your references to ML.NET are up-to-date? The latest release is version 1.3.1 for stable packages (which is most of them), and 0.15.1 for preview packages.

If that doesn't help you, please post your .csproj.

Eric Erhardt
  • 2,286
  • 15
  • 19