无法在visual studio 2015中引用libsodium.dll [英] Unable to reference libsodium.dll in visual studio 2015

查看:113
本文介绍了无法在visual studio 2015中引用libsodium.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Argon2密码哈希方法。我用谷歌搜索它,发现它需要libsodium.dll,所以从github下载了libsodium.dll的zip文件,它位于下面

https://github.com/adamcaudill/libsodium-net/releases



并试图将libsodium.dll添加到我的项目中,它抛出了这个错误。

错误:对'C:\\的引用无法添加\\ libsodium-net.v0.9.0 \libsodium.dll'。请确保该文件是可访问的,并且它是有效的程序集或COM组件。





我试图弄清楚如何使用libsodium和Argon2进行密码散列以及如何在将libsodium.dll添加到我的项目时解决错误。请建议!!!



我尝试过:



我从NuGet软件包安装'libsodium for .NET 0.9.0',它添加了sodium.dll,但它没有我想要的Argon方法。



我正试图找到解决这个问题的方法,我找到了这个,

https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016



如果我添加libsodium.dll,我认为这对我有帮助。尝试使用该URL的C#.Net哈希方法,但它在ArgonHashString方法中抛出错误。



var hash = PasswordHash.ArgonHashString(yourPasswordString,Strength.Interactive)

if(PasswordHash.ArgonHashStringVerify(hash,yourPasswordString){

//正确的密码

}



我试图通过将libsodium.dll复制到我项目的bin中并通过复制dll来添加引用:C:\Program Files \Reference Assemblies\Microsoft \ VSTO40 \v10。 0.它抛出了同样的错误。我尝试通过将libsodium.dll移动到不同的文件夹来添加它。通过添加其他dll到我的项目进行测试,添加其他dll时没有问题。

I am trying to use the Argon2 Password Hashing method. I googled it and found that it requires libsodium.dll and so downloaded the zip file of libsodium.dll from github, which is below
https://github.com/adamcaudill/libsodium-net/releases

And tried to add the libsodium.dll to my project, it threw this error.
Error: A reference to 'C:\libsodium-net.v0.9.0\libsodium.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM Component.


I was trying to figure out how to use libsodium and Argon2 for password hashing and how to resolve the error when adding the libsodium.dll to my project. Please suggest!!!

What I have tried:

I installed 'libsodium for .NET 0.9.0' from NuGet packages, it added sodium.dll, but it doesn't have the Argon method that I was looking for.

I am trying to find a way to solve this, and I found this,
https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016

Thought it would be helpful for me if I add the libsodium.dll. Tried with hasing method for C#.Net from that URL, but it was throwing error at ArgonHashString method.

var hash = PasswordHash.ArgonHashString(yourPasswordString, Strength.Interactive)
if (PasswordHash.ArgonHashStringVerify(hash, yourPasswordString) {
//correct password
}

I tried to add the reference by copying the libsodium.dll to the bin of my project and by copying the dll yo C:\Program Files\Reference Assemblies\Microsoft\VSTO40\v10.0. It threw the same error. I tried to add the libsodium.dll by moving it to different folders. Tested by adding other dlls to my project and there is no issue when adding other dlls.

推荐答案

仔细检查DLL - 错误基本上是这不是程序集,这意味着它是一个本机DLL。

你不能引用本机DLL ,只有.NET一个也有帮助的程序集如果文件带有DLL扩展名。

必须通过PInvoke访问本机文件。
Check the DLL carefully - the error is basically saying "this isn't an Assembly" which means it's a native DLL instead.
You can't reference a native DLL, only .NET an assemblies which are also helps if files with a DLL extension.
Native files have to be accessed via PInvoke instead.


这篇关于无法在visual studio 2015中引用libsodium.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆