error while getting a response from stripe "Could not load file or assembly 'System.Collections.Immutable'


Stripe Library referenced :
Runtime Version:v4.0.30319
Version :

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=, Culture=neutral" on the code mentioned below

<form action="/Pay/Charge" method="POST">
        <label>Amount: $5.00</label>
    <script src="//"
            data-description="Sample Charge"

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=, 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)

asked on Stack Overflow Mar 28, 2019 by Nawaz Khan

2 Answers


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="" targetFramework="net45" />


Original question was about version 25.2.0 of and in that old version there was dependency on System.Collections.Immutable, howeever latest version for has no dependency on anymore: enter image description here

Check out the link

Hope this was useful.

answered on Stack Overflow Mar 28, 2019 by Ali Ezzat Odeh • edited Jan 19, 2020 by Ali Ezzat Odeh

Here's my take when I tried to fix this problem:

  1. I needed to add 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.
  2. The 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 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:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />

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=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
answered on Stack Overflow Jan 24, 2020 by Csaba Toth

User contributions licensed under CC BY-SA 3.0