问题描述
我将libsodium-net NuGet加载到我的PoC解决方案中,并在各自的目录(System32和SysWOW64)中包含32位和64位libsodium.dll文件。每当我在调试模式下运行程序时,我都会收到BadImageFormatException错误。将libsodium.dll文件放在各自的系统目录中是否足够了,我只是遗漏了其他内容,或者我是否需要在我的解决方案中获得这些dll文件的副本?
这是我的程序,至少根据intellisense,这里的所有内容都正确连接。
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
Imports Sodium
Imports System.Text
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)
End Sub
End Class
我尝试了什么:
我尝试使用x86和x64构建配置进行编译,因为我在这里阅读: [ ]那个,那个可能是这个错误的原因,但我在这两个方面仍然有同样的错误。
我也尝试过这个问题呃我在这里找到: [],它说它也安装了Visual C ++ Redistributable 2015,但是当我尝试这个问题时,我从安装程序得到一个错误,说明它已经安装在我的电脑。当我检查时,我所拥有的只是2008年,2013年和2017年的版本,而不是2015年,所以我仍然不知道为什么我无法安装2015 Redistributable,但这是我想的另一次,除非那是唯一的解决方案将起作用,在这种情况下,是否有人知道可能导致该问题的原因?
我在NuGet经理以及libsodium和Sodium.Core中检查过是最新的并运行当前稳定的型号。我只提到了System32和SysWOW64目录,因为这是我试图找到其他人找到的解决方案并将dll放在这些目录中时已经尝试过的东西解决了一对几个人的问题所以我试着看看它是否会解决我的问题,但它没有。
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.
推荐答案
这篇关于在visual studio 17中加载libsodium.dll时出现'badimageformatexception'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!