I have the libsodium-net NuGet loaded into my PoC solution and have the 32-bit and 64-bit libsodium.dll files in their respective directories (System32 and SysWOW64). Whenever I go to run the program in debug mode, I get the BadImageFormatException error. Is it enough to have the libsodium.dll files in their respective System directories and I'm just missing something else, or do I need to have copies of those dll files in my solution as well?
Here's my procedure and at least according to intellisense, everything here's hooked up correctly.
Option Explicit On
Public Class Form1
Dim textToEncrypt, decrypted As String
Shared encoder As New UTF8Encoding
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim key, hashedBytes, salt As Byte()
textToEncrypt = TextBox1.Text
Dim textBytes As Byte() = encoder.GetBytes(textToEncrypt)
hashedBytes = CryptoHash.Sha512(textToEncrypt)
salt = PasswordHash.ScryptGenerateSalt()
key = SecretBox.GenerateKey()
Dim passEnc As Byte() = PasswordHash.ScryptHashBinary(textBytes, salt, PasswordHash.Strength.Medium)
TextBox2.Text = Convert.ToBase64String(passEnc)
TextBox6S.Text = Convert.ToBase64String(salt)
TextBox3PBK.Text = Convert.ToBase64String(key)
TextBox5H.Text = Convert.ToBase64String(hashedBytes)
What I have tried:
I have tried compiling using both x86 and x64 build configurations since I read here: c# - BadImageFormatException during .Net assembly load issue - Stack Overflow
] that, that could be the cause of this error but I still got the same error in both areas.
I also tried the answer I found here: How to include libsodium.net on ASP.NET for incorporating libsodium-net into VS
], where it said to install Visual C++ Redistributable 2015 as well, but the problem there is when I tried that, I got an error from the installer stating that it was already installed on my computer. When I checked though, all I had were the 2008, 2013 and 2017 versions, not 2015, so I'm still at a loss on why I couldn't install the 2015 Redistributable but that's for another time I suppose, unless that's the only solution that will work, in which case, does anyone know what could be causing that issue as well?
I checked in the NuGet manager and both libsodium and Sodium.Core are up to date and running the current stable models. I only mentioned the System32 and SysWOW64 directories because it was something I had tried while trying to find solutions that other people had found and placing the dlls in those directories had solved the issue for one a couple people so I tried it to see if it would solve mine as well, which it didn't.