Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automapper 3.0 - This type is not supported on this platform IMapperRegistry

I updated my project to use Automapper 3.0.0 and now my TFS build is not succeeding. The error is the following:

"...System.PlatformNotSupportedException: System.PlatformNotSupportedException: This type is not supported on this platform IMapperRegistry."

Is there anyone that can help me resolve this issue. In the mean time, I am going to revert to previous version since that one seems to work fine.

like image 844
nano Avatar asked Aug 26 '13 14:08

nano


2 Answers

We had the same issue on our build server. MsTest seemed to remove DLLs it deemed unnecessary (note : this claim is only an educated guess). To fix it, add an explicit call to something in AutoMapper.Net4.dll. For instance, with the class ListSourceMapper :

var useless = new ListSourceMapper() 

Adding this to a project which is shared by all other projects fixed it for us. Where to put this line of code may vary.

like image 57
jni Avatar answered Sep 18 '22 16:09

jni


Make sure you add a reference (or add a NuGet package reference) in your application to both AutoMapper and the AutoMapper.Net4 assembly in your main application. Visual Studio has a problem with copying references that it won't copy references that it doesn't think are being used.

For example, if you have projects: - Core - UI

And Core references AutoMapper, make sure you add a reference in UI as well to BOTH assemblies. NuGet does this automatically, but MSBuild will NOT copy all references from Core to UI. The easiest way to fix this is to simply add the AutoMapper package reference in UI.

like image 29
Jimmy Bogard Avatar answered Sep 20 '22 16:09

Jimmy Bogard