【发布时间】:2019-08-18 23:06:25
【问题描述】:
引用的条纹库:Stripe.net
运行时版本:v4.0.30319
版本:25.2.0.0
从条带获得响应并调用收费函数()时,我收到错误“无法加载文件或程序集'System.Collections.Immutable,Version=1.2.3.0,Culture=neutral” 下面提到的代码
<form action="/Pay/Charge" method="POST">
<article>
<label>Amount: $5.00</label>
</article>
<script src="//checkout.stripe.com/v2/checkout.js"
class="stripe-button"
data-key="@ViewBag.StripePublishKey"
data-locale="auto"
data-description="Sample Charge"
data-amount="500">
</script>
</form>
这个视图调用下面的charge ActionResult
public ActionResult Charge(string stripeEmail, string stripeToken)
{
var customers = new CustomerService();
var charges = new ChargeService();
var customer = customers.Create(new CustomerCreateOptions
{
Email = stripeEmail,
SourceToken = stripeToken
});
//Error on this line--↓
var charge = charges.Create(new ChargeCreateOptions
{
Amount = 500,
Description = "Sample Charge",
Currency = "usd",
CustomerId = customer.Id
});
// further application specific code goes here
return View();
}
Additional information: Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
InnerException:Null
【问题讨论】:
-
作为一个nuget包,你确定它已经发送到服务器了吗?
-
错误信息的重要部分是
The located assembly's manifest definition does not match the assembly reference.。这意味着您使用的'System.Collections.Immutabledll 与库预期的不同。如果您搜索错误消息,您会发现很多重复项。解决方案是在您的 web.config 中添加一个绑定重定向,该重定向指向您添加到项目中的 dll 版本。如果您通过 NuGet 添加该程序集,则会自动添加绑定重定向元素 -
这是一个演示项目,我正在我的本地机器上尝试@BugFinder
-
System.Collections.Immutable 的最新稳定版本是 1.5。添加该版本并确保 web.config 包含重定向到此的条目
-
Stripe.NET 26.1.0 也面临同样的问题。而现在
System.Collections.Immutable的最新版本是 1.7.0。我假设它向后兼容 1.2.3.0,我不明白为什么 Stripe.NET 会在这种传递依赖上绊倒......
标签: c# .net asp.net-mvc stripe-payments