AutoMapper: Mapping Com Object: Missing type map configuration or unsupported mapping.
I try to map a Interop Com Object to a .Net Object and getting a exception:
Missing type map configuration or unsupported mapping.
Mapping types:
ProjectTimeRecord -> TimeRecord
ComTimeRecording.ProjectTimeRecord -> AutoMapperTest.TimeRecord
Destination path:
TimeRecord
Source value:
System.__ComObject
The Interop library is a private dll, I cloud not share. I write minimal code to reproduce:
class TimeRecord
{
public int Id { get; set; }
}
class Program
{
static void Main(string[] args)
{
ProjectTimeRecord projectTimeRecord = GetRecord();
Console.WriteLine(projectTimeRecord.GetType());
// Output: "System.__ComObjects"
Mapper.CreateMap<ProjectTimeRecord, TimeRecord>();
// Exception in next line
TimeRecord record = Mapper.Map<ProjectTimeRecord, TimeRecord>(projectTimeRecord);
Console.WriteLine(record.Id);
}
}
I use VS2015 RC, .NET 4.6 RC and AutoMapper 4.0.0-ci1061. On StackOverflow is a question with the same exception
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 17 (10 by maintainers)
Here’s an implementation for AutoMapper 6: https://gist.github.com/kbkk/437d92af4f3fc72ee9040f633d0ce988
This will output ApplicationClass, not __ComObject. And the mapping will work.