12

I just installed AutoMapper, via nuGet, on a new project, but when I run the code, I get the following error:

Could not load file or assembly 'AutoMapper, Version=2.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Why is it looking for Version=2.2.1.0, and what can I do about it? Revert to that version?

dove
  • 20,469
  • 14
  • 82
  • 108
ProfK
  • 49,207
  • 121
  • 399
  • 775

4 Answers4

12

You probably just want to add a binding redirect for AutoMapper as one of your references is looking for version 2.2 specifically

This should do it:

 <dependentAssembly>
      <assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" 
                     culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
    </dependentAssembly>
dove
  • 20,469
  • 14
  • 82
  • 108
  • in fact I just updated to 3.0 and got the issue you had and fixed it by adding this binding redirect. if you have .net reflector you could probably see what has this reference but it is probably rather academic really. – dove Sep 02 '13 at 15:03
4

Try uninstalling and reinstalling AutoMapper again.

If you have multiple projects in your solution chances are that you have version 2.2.1.0 already installed in one of your projects. But latest version of AutoMapper is 3.0.0 so this is why you got problems.

TheNick
  • 69
  • 1
  • 5
  • This is entirely possible. I will double check that as soon as I get to work on the code again tonight. – ProfK Sep 02 '13 at 14:33
1

Problem:

Could not load file or assembly 'AutoMapper, Version=3.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Solution:

Add assemblyBinding to yur app.config files:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.1.0" newVersion="3.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Clean, Rebuild solution and smile! :-)

juFo
  • 17,849
  • 10
  • 105
  • 142
0

I had the same error and was able to fix by setting Enable 32-Bit applications to True on the App Pool

Aussie Ash
  • 1,276
  • 12
  • 10