Stripe Library referenced : Stripe.net
Runtime Version:v4.0.30319
Version : 25.2.0.0
while getting a response from the stripe and calling the charge function() in am getting the error "Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0, Culture=neutral" on the code mentioned below
<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>
This view calls the below 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
In case System.Collections.Immutable is already installed, Check out the version of it in packages.config in case it is a different version it won't work, modify it manually to be the same version as it is logged in the exception and rebuild your solution to install the needed version.
<package id="System.Collections.Immutable" version="1.2.3.0" targetFramework="net45" />
Update:
Original question was about version 25.2.0 of Stripe.net
and in that old version there was dependency on System.Collections.Immutable
, howeever latest version for has no dependency on anymore:
Check out the link Stripe.net
Hope this was useful.
Here's my take when I tried to fix this problem:
System.Collections.Immutable
to my web.config
file (or if you happen to work on a desktop app it's the app config). Before this error there wasn't an entry for that assembly in the web.config.NuGet
package version is not the same as the assembly version for whatever reason. This hindered me for several hours, because I knew I had to add a version redirection to my web.config
.Currently the NuGet
package version is 1.7, while the assembly version is 1.2.5.0
. Finally I found that out with PowerShell
:
PS> [Reflection.AssemblyName]::GetAssemblyName('C:\Users\MyUserName\Documents\WebAppSourceCodePath\bin\System.Collections.Immutable.dll').Version
Major Minor Build Revision
----- ----- ----- --------
1 2 5 0
Knowing that I added this entry:
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="1.2.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
...
</configuration>
Also, you need the proper publicKeyToken
and full specification in the entry above. That can be read out using PowerShell as well.
PS> [System.Reflection.Assembly]::LoadFile('C:\Users\MyUserName\Documents\WebAppSourceCodePath\bin\System.Collections.Immutable.dll').FullName
System.Collections.Immutable, Version=1.2.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
User contributions licensed under CC BY-SA 3.0