question

SaraLane-2191 avatar image
0 Votes"
SaraLane-2191 asked DanielZhang-MSFT edited

ML.Net in .NET Framework Project

I have a Windows Forms project that targets the .NET Framework 4.6.1. I'd like to add machine learning capabilities to the project, so I added a new project that implements ML.NET. All of the projects in the solution are targeting x64.

The project works perfectly in the debugger, but I get the following error when I try running the published app:

System.DllNotFoundException
at Microsoft.ML.Internal.CpuMath.Thunk.DotU

I've tried using version 1.3.1 of ML.NET and I also installed Microsoft Visual C++ redistributable in the client machine but same result.

How can I resolve this or do I have no choice but to migrate my whole solution to .NET Core?

windows-formsdotnet-ml-big-data
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please start from posting a complete error message. If System.DllNotFoundException points to CpuMathNative, then it has been thoroughly covered in GitHub issues like this.

0 Votes 0 ·

Thank you for taking the time to respond.

It points to CpuMath, not CpuMathNative. I've looked through many similar Github issues but so far none of the solutions have worked for me. Right now I'm using ML.NET version 1.6.0, and everything is targeting x64.

0 Votes 0 ·

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered DanielZhang-MSFT edited

Hi SaraLane-2191,
Please refer to the following suggestions:
1.Open the package folder on your solution and browse \packages\Microsoft.ML.CpuMath.0.10.0\runtimes\win-x64\native, and copy it to your bin folder.
2. Use PackageReference instead of packages.config.
More details please refer to this blog.
3.Include the ML.Net via .csproj file.
And eerhardt has pionted out in this thread.
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello Mr. Zhang,

Thank you for your response.

I tried your first two suggestions with no success, and I wasn't clear what you meant by the 3rd suggestion. I looked at the link regarding eerhardt but he seems like he's talking about version 1.4.0 of ML.NET, and I'm using version 1.6.0.

I am posting more of the error below (I can't post the whole thing due to character constraints). Thank you for your time!

Application: CentralTest.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException
at Microsoft.ML.Internal.CpuMath.Thunk.DotU(Single*, Single*, Int32)
at Microsoft.ML.Numeric.VectorUtils.DotProductWithOffset(Microsoft.ML.Data.VBuffer`1<Single> ByRef, Int32, Microsoft.ML.Data.VBuffer`1<Single> ByRef)


Exception Info: System.AggregateException
at Microsoft.VisualBasic.CompilerServices.Symbols+Container.InvokeMethod(Method, System.Object[], Boolean[], System.Reflection.BindingFlags)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateGet(System.Object, System.Type, System.String, System.Object[], System.String[], System.Type[], Boolean[])
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(System.Object, System.Type, System.String, System.Object[], System.String[], System.Type[], Boolean[])
at LaborPrediction.LaborModel.PrepareAndTrainModel()
at Central.ProcessCode.Main()

0 Votes 0 ·

Hi @SaraLane-2191,
>> but he seems like he's talking about version 1.4.0 of ML.NET, and I'm using version 1.6.0.
What he means is that a code example is provided for the 1.4.0 version of ML.NET, you can change it to your own 1.6.0 path.
And do you still get the same error after trying the suggestions?
You can try to use the .NET Framework version 4.7.2 or higher.
Best Regards,
Daniel Zhang

0 Votes 0 ·

Hello Mr. Zhang,

I'm sorry for the delayed response. My company performed updates on the network and I was hoping one of the updates would help with this issue but unfortunately that didn't happen.

I've tried all of your suggestions, but I'm still getting the same error.

I'm targeting x64 and .NET Framework 4.5.2 or 4.6.1 (there are 14 projects in the solution). Do they all need to target 4.7.2 for it to work?

Thank you for your help!

0 Votes 0 ·
Show more comments