title: How can I convert from a byte[] to a string using AutoMapper?
body: <p>I'm getting the following error in AutoMapper when trying to convert an object with a property that is of type byte[] to an object with a matching property of type string:</p>
  <blockquote>
  <p>System.InvalidOperationException: Missing map from System.Byte to System.Char. Create using CreateMap&lt;Byte, Char&gt;.</p>
  </blockquote>
  <p>I tried using custom type converters, but they didn't seem to work (same error with or without them). I was able to map the specific property, but I'm trying to create something that can be applied to an entire project (most of my entities include a RowVersion that is intended to be used for optimistic locking).</p>
  <p>My code look something like this...</p>
  <pre class="lang-cs prettyprint-override"><code>public class AutoMapperProfile : AutoMapper.Profile
  {
      public AutoMapperProfile()
      {
          CreateMap&lt;byte[], string&gt;().ConvertUsing&lt;ByteArrayToStringTypeConverter&gt;();
          CreateMap&lt;string, byte[]&gt;().ConvertUsing&lt;StringToByteArrayTypeConverter&gt;();
          CreateMap&lt;MyFirstClass, MySecondClass&gt;();
      }
  }
  public class MyFirstClass
  {
      public string Name { get; set; }
      public byte[] RowVersion { get; set; }
  }
  
  public class MySecondClass
  {
      public string Name { get; set; }
      public string RowVersion { get; set; }
  }
  
  public class ByteArrayToStringTypeConverter : ITypeConverter&lt;byte[], string&gt;
  {
      public string Convert(byte[] source, string destination, ResolutionContext context)
      {
          return System.Convert.ToBase64String(source);
      }
  }
  
  public class StringToByteArrayTypeConverter : ITypeConverter&lt;string, byte[]&gt;
  {
      public byte[] Convert(string source, byte[] destination, ResolutionContext context)
      {
          return System.Convert.FromBase64String(source);
      }
  }
  </code></pre>
  <p>This is in a .Net 5, ASP.Net Core, Web API project.</p>