title: Why do I get "Missing type map configuration or unsupported mapping" error in automapper?
body: <p>Code: </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using AutoMapper;
  
  namespace TestAutomapper
  {
    class Program
    {
      static void Main(string[] args)
      {
  
        var config = new MapperConfiguration(cfg =&gt; cfg.CreateMap&lt;MyClassSource, MyClassDestination&gt;());
  
  
        var mapper = config.CreateMapper();
  
        var source = new MyClassSource { DateTimeValue = null };
  
        var mapped = mapper.Map&lt;MyClassSource, MyClassDestination&gt;(source);
      }
  
    }
  
    public class MyClassSource
    {
      public object DateTimeValue { get; set; }
    }
  
    public class MyClassDestination
    {
      public DateTime? DateTimeValue { get; set; }
    }
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>    AutoMapper.AutoMapperMappingException was unhandled
        HResult=-2146233088
        Message=Error mapping types.
  
      Mapping types:
      MyClassSource -&gt; MyClassDestination
      TestAutomapper.MyClassSource -&gt; TestAutomapper.MyClassDestination
  
      Type Map configuration:
      MyClassSource -&gt; MyClassDestination
      TestAutomapper.MyClassSource -&gt; TestAutomapper.MyClassDestination
  
      Property:
      DateTimeValue
        Source=Anonymously Hosted DynamicMethods Assembly
        StackTrace:
             at lambda_method(Closure , MyClassSource , MyClassDestination , ResolutionContext )
             at TestAutomapper.Program.Main(String[] args) in C:\Users\costa\documents\visual studio 2015\Projects\TestAutomapper\TestAutomapper\Program.cs:line 22
             at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
             at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
             at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
             at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
             at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
             at System.Threading.ThreadHelper.ThreadStart()
        InnerException: 
             HResult=-2146233088
             Message=Missing type map configuration or unsupported mapping.
  
      Mapping types:
      Object -&gt; Nullable`1
      System.Object -&gt; System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
             Source=Anonymously Hosted DynamicMethods Assembly
             StackTrace:
                  at lambda_method(Closure , Object , Nullable`1 , ResolutionContext )
                  at lambda_method(Closure , MyClassSource , MyClassDestination , ResolutionContext )
             InnerException: 
  </code></pre>
  
  <p>I thought this error was solved (<a href="https://github.com/AutoMapper/AutoMapper/issues/1095" rel="nofollow">https://github.com/AutoMapper/AutoMapper/issues/1095</a>). I am using Automapper 5.1.1.</p>
  
  <p>How do I fix this?</p>
  
  <p>Thanks</p>
  
  <p>Edit: Just to clarify, I am concerned with the handling of the null value. I understand that converting from a non-null object value to DateTime is complicated. In the real code, the actual value in the source object is null or DateTime. I thought the null is handled without errors.</p>
  
  <p>Edit:</p>
  
  <p>I created an extension method ToDate to convert an object to a date and I added this mapping to handle conversions from object to DateTime?:</p>
  
  <pre><code>cfg.CreateMap&lt;object, DateTime?&gt;().ConstructUsing(src =&gt; src.ToDate());
  </code></pre>