简体   繁体   中英

Referenced Nuget DLL Not Found Working Visual Studio

I added a Nuget library called Mpir.Net, which specializes in manipulating gigantic numbers much faster than the in-built BigInteger class does. When I added it in, Visual Studio 2017 was able to find the DLL, add it into my references, and provide suggestions based on the variables and functions defined in the DLL. Visual Studio was clearly able to find the DLL, unlike many questions on here from people with similar problems.

The problem is that when I run the program, it says xmpir64.dll not found, even though Visual Studio can reference things inside it in the code editor.

I've tried changing the target .NET version to no avail. What is the problem? As a side note, I'm very new to C# and Visual Studio, so please keep that in mind when answering. Here is a link to a picture of my solution explorer.

Mpir.Net is a wrapper around an unmanaged library (GMP). When it says it's unable to find the DLL, it's because it's looking for the unmanaged one (xmpir64.dll) which is in your project folder (not the managed one in the references, which is the wrapper).

You probably just need to click on xmpir64.dll (and the x32 one too), look at its properties in the bottom right, and ensure copy to output directory is set to "copy always".

As a side note, Mpir.NET does not dispose of its unmanaged resources correctly, so don't be surprised if you have a big memory leak. I don't think I'd use it for commercial code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM