Getting libsodium to work on Windows
Last updated
Last updated
libsodium requires the on Windows. This dependency is included in the .NET SDK. When publishing software, there are three ways to deal with this:
Install this as part of your application setup/as a .
Ask the user to manually install this.
Bundle the vcruntime140.dll
file with your executable.
If you want your program to be portable (e.g. ), you have to take the third approach. This can be done using the following steps:
Download the VisualCppRedist_AIO_x86_x64.exe
file from the of GitHub repo.
Use to extract the downloaded executable (e.g. right click, hover over 7-Zip, and click Extract to "VisualCppRedist_AIO_x86_x64\").
In the extracted folder, navigate to 2022
, x86
and/or x64
(depending on which platform your application targets), System
or System64
, and copy the vcruntime140.dll
file(s) to your project folder.
Add the vcruntime140.dll
file(s) as in your project.
Write some code that extracts the relevant (x86 or x64) file to the or to the when your application starts.
Test that libsodium in your application works/doesn't throw a PlatformNotSupportedException
on a Windows machine that doesn't have the Visual C++ Redistributable installed (e.g. in or a ).