-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Unable to load DLL 'CpuMathNative' #3764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I figured that the file is on my devbox. Probably it is not put to the release folder because there is a x86 and a x64 version of it, with the project set to Therefore I would like to deploy both DLLs to the target devices, but don't know how I can have the project (a library on its own) to look it up in the respective folders, without needing to generate two separate projects/installers etc.?
|
@korneliuscode .. let me take a look at this. will keep u posted. |
@korneliuscode . For the .NET standard project where you added ML.NET you can keep it as AnyCPU. However, you need to specify either x86 or x64 in your .NET Framework 4.7.2 project |
The assembly that is causing an issue is the There is no such thing as "any CPU" for C/C++ - you need to compile it for a specific processor architecture. We compile This works great on .NET Core, because .NET Core has the concept of a "portable" application - meaning it can run either x86 or x64, Windows or Linux or macOS. The way native assemblies work on .NET Core, is they all get put into a However, on .NET Framework this doesn't work. The .NET Framework doesn't have the same capability to pick a native asset based on the current process. So instead, if you have native dependencies (like ML.NET does) you need to build a .NET Framework application for the specific architecture you expect it to run on. If you need it to run on both 32-bit and 64-bit, then you will need to build 2 versions of it - one with the x86 native binaries and one with the x64 native binaries. There are ways to pick the native assets yourself on .NET Framework, but I would consider them to be advanced scenarios. If you are curious, one example is how DiaSymReader works with its native assets: The idea here would be to deploy both the Like I said, I'd consider that an advanced approach, and I would recommend building your .NET Framework Exe project as |
@korneliuscode .. hope the above explanations helped and we can close this issue. |
Thanks for the explanation. As always in life I have to cater for some legacy users also. Therefore it's not easy to introduce two different versions (x86/x64) or a new type of installer of the app or switch fully to .NET Code (due to remaining winforms components). I'll have a look at the dynamic loading based on the bitness of the OS. I wonder if this works even though my app is not "directly" using the native dll. |
Are you explicitly using AnyCPU or are you using AnyCPU32bitpreferred (the default)? If you have "Prefer 32-bit" checked, your app will run as 32-bit on both 32-bit and 64-bit Windows. Which means you would only need to deploy the Check out https://dzone.com/articles/what-anycpu-really-means-net for more details. |
Thanks for the tip. For now I still use the |
Closing this issue. Does not require a code fix for ML.NET |
Exception thrown: 'System.DllNotFoundException' in Microsoft.ML.CpuMath.dll the above error is shown at this line: trying to implement sentimental analysis on input comments in ASP.NET WEB APPLICATION(.NET FRAMEWORK) but getting these error even though it is seen in solution explorer. |
I am having the same issue. Changing to x86 or x64 does not correct the problem. |
@pjmelvin - can you try with the latest pre-release version of ML.NET? https://www.nuget.org/packages/Microsoft.ML/1.5.0-preview. If that doesn't fix your issue, please open a new issue to track it with full repro steps - https://github.com/dotnet/machinelearning/issues/new |
This issue terrifies my boss and makes him afraid to use this package. We will not be on .net core anytime soon. |
@andrewkittredge - I can help calm some fears here. ML.NET does work on .NET Framework, with one caveat: your application needs to specifically target 32-bit or 64-bit. Your app (the project that produces an There was a bug shipped in version Hope this helps. |
See #4870. |
@Hrishikesh46779 - it looks like you are using Xamarin, is that correct? Xamarin will be supported in .NET 6 (releasing this fall) when it supports the hardware intrinsics APIs that were introduced in .NET Core 3. If you want to try it out now using the .NET 6 Preview, check out https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-6/. |
Yes i am using xamarin. Nice to know that it will be supported. |
System information
Issue
Created a new .net standard project, added ML.NET from nuget and added the project to my existing solution (.net Framework 4.7.2). Both are set to Any CPU, as I read that ML.NET also supports x86. The DLL Microsoft.ML.CpuMath.dll is present in the release folder.
Source code / logs
The text was updated successfully, but these errors were encountered: