- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个基于 ASP.NET(使用 .asmx)文件构建的旧 Web 服务。我需要使用 sodium.net - 不幸的是它在加载依赖的 libsodium.dll 文件时失败了。关于我做错了什么有什么想法吗?
我已经通过 NuGet 添加了 libsodium.net。
我已将 64 位 DLL 重命名为“libsodium.dll”(以及其他命名约定)。
我尝试直接引用 libsodium.dll,但 VS 拒绝它(不是有效的 DLL)。所以我将其添加为“内容”而不是“复制到输出”。
构建后我可以看到 website/Bin 文件夹同时包含 sodium.dll(.NET 程序集)和 libsodium.net。
当我尝试使用 libsodium.net 时,我得到:
错误 2015-02-02 11:14:27,118 13798 毫秒 [41] CabinetService doRequest - 捕获:'Sodium.SodiumCore' 的类型初始值设定项抛出异常。System.TypeInitializationException:“Sodium.SodiumCore”的类型初始值设定项引发异常。 ---> System.DllNotFoundException: 无法加载 DLL 'libsodium.dll': 找不到指定的模块。 (HRESULT 异常:0x8007007E) 在 DynamicDllInvokeType.sodium_init() 在 Sodium.SodiumCore..cctor() --- 内部异常堆栈跟踪结束 --- 在 Sodium.SodiumCore.LibraryName() 在 Sodium.SecretBox.Create(字节 [] 消息,字节 [] 随机数,字节 [] 键) 在 Macaroons.SecretBoxCryptoAlgorithm.Encrypt(Byte[] key, Byte[] plainText) 在 c:\Projects\Macaroons.Net\Macaroons.Net\SecretBoxCryptoAlgorithm.cs:line 58
所以它找不到“libsodium.dll”,即使它在 Bin 文件夹中。我也确实尝试删除对“sodium.net”的依赖,在我收到运行时错误说“sodium.net”丢失后 - 当我重新添加它时,该错误消失了,我得到了上面的那个(表示“sodium.net”正确加载)。
所以我打开“C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\cabinetservice”中的网站影子文件夹并搜索“sodium”。唯一的结果是某些子文件夹中的“sodium.dll”。没有“libsodium.dll”。
显然 ASP.NET 在创建网站的卷影副本时忽略了“libsodium.dll”文件。
我还尝试将 libsodium.dll(32 位)添加到 C:\Windows\System32 并将 libsodium.dll(64 位)添加到 C:\Windows\SysWOW64。相同的结果。
我试过 C:\Windows\Microsoft.NET\assembly\GAC_32\libsodium 和 C:\Windows\Microsoft.NET\assembly\GAC_64\libsodium。相同的结果。
如何让 ASP.NET 知道依赖关系?
最佳答案
事实证明,ASP.NET 不会为非托管 DLL(例如 libsodium.dll 和 libsodium-64.dll)创建卷影副本。
Sodium.dll(托管代码)尝试从与 Sodium.dll 的卷影副本相同的目录(这是行不通的)或 PATH 环境变量目录中的某个位置加载 DLL。
我的解决方案是在调用任何 Sodium 代码之前将 AppDomain\Bin 目录添加到路径中:
// Make it possible to load unmanaged libsodium DLLs that .NET does not make shadow copies of.
// -> Simply point the "path" variable to the Bin directory.
string path = Environment.GetEnvironmentVariable("PATH");
string binDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Bin");
Environment.SetEnvironmentVariable("PATH", path + ";" + binDir);
2018 年 1 月更新(来自 Jordan Rieger 的回答):
Note that you may also need to install the Microsoft Visual C++ 2015 Redistributable on your server (either the x64 or x86 target, depending on your process.)
Don't forget to restart your app pool (I did an IIS reset) after installing the redistributable.
关于c# - 如何在 ASP.NET 上包含 libsodium.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28275944/
我通过 NuGet 安装了 Libsodium-net 并且能够在我的类中包含 Sodium,但是当我尝试运行它时,我得到了 Sodium.dll 中发生了“System.DllNotFoundExc
我需要在我的 Ubuntu (14.04) 服务器上的 PHP(5.5.9) 应用程序中加密密码和一些其他数据。我阅读了 libsodium,发现它非常适合应用程序要求。我遵循了唯一的 tutoria
我一直在努力使用 crypto_secretbox_easy() 在 libsodium 中加密/解密一些数据| .我似乎找不到关于使用的任何好的文档。 我想从用户那里获取密码,用它来以某种方式制作
功能 int crypto_sign(unsigned char *sm, unsigned long long *smlen, const unsigned char *m,
我在嵌入式设备上使用 libsodium。我想与移动设备交互以进行 key 生成/加密/解密。 是否有必要在所有参与加密通信的设备上使用 libsodium? 换句话说:libsodium 包装了 N
我正在编写一个应用程序,用户可以在其中通过端到端加密在设备之间进行通信。为此,我使用 libsodium 加密库。非对称加密函数 crypto_box(...) 需要一个随机数作为参数之一。 我对如何
我想用 libsodium 中的公私 key 方法加密一个大文件(100 MB)。对于小消息,我使用 crypto_box_easy() ,但这不适用于大文件。最好的使用方法是什么crypto_box
我一直在使用 PHP 中的 openssl 库来生成用于 RSA 加密的 key 对,并且看到在最新版本的 PHP 7.2 中,现在已经集成了 libsodium。 我想更新到较新的库,并且可以生成
RFC 7539定义其 AEAD 构造如下: chacha20_aead_encrypt(aad, key, iv, constant, plaintext): nonce = constant
我正在尝试在扩展程序中使用 libsodium.js 库,到目前为止只在 Chrome(当前版本 71)中进行了测试。 到目前为止,它在标准网页上下文中运行良好,但是当我尝试在扩展中加载它时,出现错误
在我的 C++ 项目中,我使用 libsodium 库来创建和验证消息的签名。 为了验证签名,我以这种方式使用 libsodium crypto_sign_open 函数 bool Signature
我正在尝试在 C++ 项目中使用 libsodium 库,但在将静态 Libsodium 库链接到我创建的共享对象时遇到了困难。该项目正在使用 G++ 编译,并设置为使用 C++11 标准。 在阅读了
我一直在努力使用 libsodium 中的 crypto_secretbox_easy() 来加密/解密一些数据。 .我似乎找不到任何关于用法的好文档。 我想从用户那里得到一个密码,用它来生成一个 k
我正在使用以下函数使用 libsodium 创建一个密封盒: void encrypt_message(char *msg, char *enc_msg, int db_id) { unsig
我想知道为 crypto_stream_salsa20_xor 提供与明文和密文相同的缓冲区是否安全。我试图查看源文件。 crypto_stream_salsa20_xor使用了crypto_core
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我计划将一堆记录存储在一个文件中,然后用 libsodium 对每个记录进行签名。 .但是,我希望我的程序的 future 版本能够检查当前版本所做的签名,反之亦然。 对于当前版本的钠,签名是使用 E
我正在使用 libsodium 通过 xchacha20poly1305 结构加密文件。我按照文档 (https://download.libsodium.org/doc/secret-key_cry
我正在查看 libsodium,特别是对称加密选项 XChaCha20-Poly1305 .我无法理解的是,libsodium 似乎没有提供加密库中常见的“上下文/更新/最终确定”工作方式。 从 li
我正在尝试安装 libsodium(按照本指南 https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsod
我是一名优秀的程序员,十分优秀!