AutoMapper 3.0.0 issue: “Could not load file or assembly ‘AutoMapper.Net4′”

Today, I installed AutoMapper 3.0.0 (what a great tool, BTW). I ran into the following issue:

My WPF (.NET 4.5) app has several separate projects, and I want to add AutoMapper (via Nuget) to a project that is not the startup project.

This results in the following error being thrown, upon the first interaction with AutoMapper (typically Mapper.Initialize(…) or Mapper.CreateMap<…>):

Could not load file or assembly 'AutoMapper.Net4, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

When checking the output dir, the AutoMapper.dll and .xml are both copied to the output dir of the startup project, but not AutoMapper.Net4.dll (and yes – ‘copy local’ is set to true).

A post-build event can fix this issue:

copy "$(TargetDir)AutoMapper.Net4.dll" "$(ProjectDir)..\[your startup project's dir]\$(OutDir)"

Maybe not the ideal way to “fix” this – but it works.

Posted in Programming Tagged with: ,

Leave a Reply

About Thomas

My name is Thomas Hjorth Biilmann. I'm a pragmatic, humorous, floorball-playing computer programmer living in Denmark, along with 5,5 million other shiny happy people.
I work for DanPilot - Denmark's largest maritime pilotage service provider - where I design and implement systems that are at the very core of the business.
I am also the father of three little princesses - because that is what real Kings produce.
Subscribe via RSS
Use: http://biilmann.dk/?feed=rss2