无法加载文件或程序集“BouncyCastle.Crypto,Version = 1.8.1.0,Culture = neutral,PublicKeyToken = null”或其某个依赖项。

5

我正在尝试将Walmart .NET SDK集成到.NET 4.61 MVC 5应用程序中。使用NuGet,我添加了对BouncyCastle.Crypto 1.8.1.0的引用。

该SDK使用.NET Standard 1.3,并引用BouncyCastle.Crypto 1.8.1.3:

https://github.com/walmartlabs/partnerapi_sdk_dotnet

1.8.1.3 在 .NET 4.61 中不可用。

{"Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null"}

=== Pre-bind state information ===
LOG: DisplayName = BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/example_user/Source/Workspaces/CCC/Test/example_app.Test.DataAccessUnitTest/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : Walmart.Sdk.Base, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\example_user\Source\Workspaces\CCC\Test\example_app.Test.DataAccessUnitTest\bin\Debug\example_app.Test.DataAccessUnitTest.dll.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/example_user/Source/Workspaces/CCC/Test/example_app.Test.DataAccessUnitTest/bin/Debug/BouncyCastle.Crypto.DLL.
LOG: Attempting download of new URL file:///C:/Users/example_user/Source/Workspaces/CCC/Test/example_app.Test.DataAccessUnitTest/bin/Debug/BouncyCastle.Crypto/BouncyCastle.Crypto.DLL.
LOG: Attempting download of new URL file:///C:/Users/example_user/Source/Workspaces/CCC/Test/example_app.Test.DataAccessUnitTest/bin/Debug/BouncyCastle.Crypto.EXE.
LOG: Attempting download of new URL file:///C:/Users/example_user/Source/Workspaces/CCC/Test/example_app.Test.DataAccessUnitTest/bin/Debug/BouncyCastle.Crypto/BouncyCastle.Crypto.EXE.

1
该dll文件不在您的bin文件夹中(无论是debug还是release)。为了证明我是正确的,请将BouncyCastle放入适当的bin文件夹中。如果这样可以解决问题,请执行以下操作:添加现有项目,然后浏览BouncyCastle可执行文件。编译器将在每次构建时将最新的BouncyCastle复制到bin文件夹中。 - jdweng
嗨,我没有看到Bouncy Castle的EXE文件,因为我正在使用.NET 4.61,而不是.NET Core。该.DLL文件存在于我的软件的调试文件夹中。 - Joseph Anderson
3个回答

3

我的问题是在同一个解决方案中同时进行项目构建,其中一个项目通过NuGet引用了一个较旧的库,有时它会覆盖最新的库。在此项目中升级NuGet包可以解决这个问题。


1
这确实帮了我。谢谢。 - bantya
1
我很高兴它有所帮助。 - ceztko

2

我不得不使用.NET 46解决方案。Walmart.Sdk.Base程序集是基于.NET Standard 1.3构建的。我需要引用针对.NET 4.6的程序集。


0

这个错误表示.. BouncyCastle.Crypto.dll文件不存在于项目的bin文件夹中。我将dll文件从旧项目复制到了bin文件夹中。这对我有用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接