0

Is it possible to use automapper in .net 4.5? Basically, can it be used with any non core .net version? I looked on the official site and I only see mentions of .net core and nuget packages.

I attempted to add it as a nuget package and got the error: Severity Code Description Project File Line Suppression State Error Could not install package 'AutoMapper 9.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

mo_maat
  • 2,110
  • 12
  • 44
  • 72
  • Perhaps, you know, try it? :) – Lucian Bargaoanu Mar 30 '20 at 03:52
  • So you downvote based on the assumption that I have not tried it? Perhaps I have tried it? I'm using a .net 4.7 app. I attempted to add it as a nuget package and got the error: `Severity Code Description Project File Line Suppression State Error Could not install package 'AutoMapper 9.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. ` Any thoughts? – mo_maat Mar 30 '20 at 03:59
  • OK, but look at the error message. Which is it? – Lucian Bargaoanu Mar 30 '20 at 04:19
  • Sorry, it is 4.5. I've corrected and added to the question. – mo_maat Mar 30 '20 at 04:27
  • What you can do is to go to nuget and start checking the versions from the top. The first that targets 4.5 is the one you can use. Or target at least 4.6.1 and use the latest. Clearly the latter is the best if at all possible. – Lucian Bargaoanu Mar 30 '20 at 04:35
  • Ok. Will try. Thanks. If upgrading is an option maybe I'll do that. But are there any alternative mappers out there? – mo_maat Mar 30 '20 at 04:59
  • More than a few :) But I guess you need some sort of guiding principle to choose one. And supporting .net 4.5 is not it. – Lucian Bargaoanu Mar 30 '20 at 05:02
  • I see. What would those guiding principles be? I looked for automapper cause that's all I've ever used. If there is something out there that will perform the same function of mapping one object to another similar to what automapper does, then as it stands I can't think of any other principle to be guided by. I could probably do it manually or write some logic to do it, but for my simple need that may be overkill. I'll ask around and do some googling. Maybe someone else will suggest something. Thanks though. – mo_maat Mar 30 '20 at 05:10
  • Then I would just use AM. – Lucian Bargaoanu Mar 30 '20 at 05:12
  • For anyone that runs into a similar scenario here are some alternatives: https://stackoverflow.com/questions/7052002/alternatives-to-automapper. I've tried ValueInjecter and it works basically the same as Automapper for the simple task of mapping from one object to another (even similar syntax). I will try it out and learn it to see if it fits my needs. It works with my .net 4.5. – mo_maat Mar 30 '20 at 05:30
  • 2
    I know its now 2022 but I had the same problem , and however in automapper it says for .net >4.7 but still the error same as you. I downgraded the automapper to older versions and it was installed. – Sara N Oct 10 '22 at 06:57

0 Answers0