Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't AutoMapper v3 work because it's looking for v2.2.1.0?

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?

like image 253
ProfK Avatar asked Aug 31 '13 19:08

ProfK


3 Answers

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>
like image 151
dove Avatar answered Nov 18 '22 00:11

dove


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.

like image 28
TheNick Avatar answered Nov 17 '22 23:11

TheNick


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! :-)

like image 1
juFo Avatar answered Nov 17 '22 22:11

juFo